Reverse engineer database in spring data rest - java

I want to expose CRUD operations to MySql via REST apis. I have just started exploring Spring. I have found Spring rest data to be a good fit for this.
But there is only one problem, automating the generation of java model, repository classes, etc,. What are the tools available that can do this? I want this to be done without any interface, preferably via maven.

Related

Quarkus: automatically generate CRUD for Graphql endpoint

I'd like to build some website using heavily CRUD operations (like most websites I guess). I saw that Quarkus provides a way to automatically generate CRUD operations for REST endpoints as shown here (based on PanacheRepositoryResource).
However, I'd love to use a Graphql endpoint instead of REST. Any idea how to automatically generate CRUD opertaions for Graphql in Quarkus?
Unfortunately this is not supported with GraphQL right now. There is an open feature request for it: https://github.com/quarkusio/quarkus/issues/20434 - feel free to watch it or chime in there.

Swagger / Openapi with openapi-generator where do we add the business logic code?

I have to create a rest api from scratch. I have already some experience with Jersey by doing mostly everything manualy.
I wanted to do it right now as this project is new. So I am currently trying the pet store sample that is available every time I am trying an openapi 3.0 online editor.
Using openapi-generator, I have generated the spring boot server for the pet store.
There are a lot of tutorial that will stop there. I don't understand where or how do I have to add my business logic code (database access, ....).
And after that I have a question, how is the specification update is done ?
With Spring Framework, you use Repository and Entity classes to handle data layer. And then add Service classes for business logic.
https://www.baeldung.com/spring-component-repository-service
Database (example in MySql): https://spring.io/guides/gs/accessing-data-mysql/

Build OData API without Entity Framework

I have an existing web forms project which consists of 3 different projects: UI layer (Web project), Business Logic Layer and Database Project. I have already written the data access methods which connect to the database and return data to the business logic layer.
Now we need to provide a REST API, and I was thinking of using oData API along with REST. But all the examples I have seen use Entity Framework and I just cannot use Entity Framework because our data access layer returns data to the business layer, which then processes that data and adds some logic, and then present it to the UI layer.
Can I still use oData API? If yes, then will I need to create fresh methods manually for each of the complex query of oData API? How will OData API access my BL Layer?
You can do this (I have just done similar myself) but it is very hard work.
To me, OData always felt like a way of exposing the entity framework through web services so if you were to try and implement it without the entity framework you will end up spending a lot of time parsing queries to your data access layer.
If you do decide to go down this route, maybe consider only implementing part of the OData spec - work out which parts you actually want to be able to use - as it is huge and the task is daunting.
These are only from my experiences though and you may have a better data access layer API setup than I had when I started which could make things significantly easier.
EDIT to answer last question:
Will you need to create fresh methods manually for each of the complex query of oData API? This will really depend on how your data will be exposed and how your data access layer is setup.

Custom spring-data repository backend

I already have a working object storage service, developed in-house - let's call it a database. Now I would like to use spring-data for CRUD operations on it, so that in the future I can easily switch to some conventional database.
The question in: how can I implement yet another spring-data repository backend? Any guides, tutorials?
The central piece to look at is the API in the Spring Data Commons module. It effectively provides the foundation for all of the existing store implementations. The support consist of the following aspects:
Object-to-store mapping (meta-model and conversion implementation)
Repository implementation and DI container configuration support
The best way to get started is by having a look at the MongoDB module for example and mimic the implementation. We're currently working on a developer guide whose work-in-progress version you can find in the Spring Data Commons wiki.

Reverse engineering a java rest based services from database

Problem
I have a relational database schema (in Oracle, but could be in Mysql or Postgres) and I need to expose basic CRUD operations on tables with REST services, all withtout a line of code from a developer.
Constraint of my problems are: java 6/7 only (not scala, groovy, etc..), maven based solution, possibly framework agnostic (could be separated from Spring, for example).
A mandatory requirement is all of this stuff must run on Tomcat (6 or 7).
Bonus: junit of similar automated test on CRUD operation using Mocks and a webpage to test services
Possible solutions
I have already investigated into Spring Roo, not finding a decent configuration or tutorial for my problem.
I have tried to reverse-engineering database using jboss hibernate tools and fits well. Using this tool I can manage to do a maven module (a persistence jar) with all entities mapped.
But I also need a code organization using DAO pattern (to handle entities) and a service layer (to setup REST services).. and this seems to be tricky.
Edit: I've found this solution, using maven hbm2dao, I'm on right path?
Thanks for your time!
p.s: I've found this solution, seems good, but is made with python :(

Categories

Resources