I'm writing a simple 3-tier app using Spring Data:
https://github.com/jbburns/qcalendar
My idea was to have the following workflow:
- Data model is defined using liquibase -> this takes care of all DDL concerns
- Use this data model to generate Java code -> Jooq Codegen does this
- Integrate that generated code with Spring Data -> this will automagically create my REST API
Not that it matters here, but a further extension to this is:
- SpringDoc is used to generate an OpenAPI spec
- Gradle plugins are used to generate api for the front end
Basically the idea here is that the middle-tier is so simple that it can be mostly accomplished with codegen and Spring.
I currently have this entire workflow working in the aforementioned repo.
However, because the JPA Entities generated by Jooq do not include the relationship between each other, the results from the REST endpoint simply contain an ID (foreign key) to another entity as opposed to the Entity itself. That would be resolved if there was a way to get Jooq to generate JPA
My questions are:
- I'm not married to JPA... it was just the easiest way to do this. Is anyone aware of a more direct integration between Jooq and Spring Data?
- Is there a way to get Jooq CodeGen to generate the JPA relationships?
For example, Jooq currently generates the following code:
public class Ao implements Serializable {
private static final long serialVersionUID = 1L;
private Integer id;
private Integer regionId;
However, I would like it to generate:
public class Ao implements Serializable {
private static final long serialVersionUID = 1L;
private Integer id;
@ManyToOne
@JoinColumn(name="region_id", nullable=false, updatable=false)
private Region region;
TIA