i have my sql server database and i used "generate persistence mapping" in intellij to get my java classes, but the relationships defined on my sql server database were not mapped, it seems i can add them with the "add relationship" but i have a lot of tables with a lot of relationships so it is a pain in the ass to do it...
is there something that can map the database including the relationships? for example if i have a table user with a defined relationship of type one to many with a table potatoes, get a java class like this :
public class user{
private int iduser;
private String name;
private String password;
//relationship!!
private ArrayList<Potatoes>potatoes; //this is mapped like "private int id_potatoes" by intillij
public user(){}
//getters and setters
}
i´m using open JPA. amd i also can't find a way to auto generate DAO's with some basic methods (save, find, delete), i will have to code them myself!!! and im talking of atleast 40 tables!! it is ridiculous!!
i know there MUST be a way to do all this stuff automatically. oh, im using jsf 2, i dont know if that is relevant to this question anyway.
Generate a database entityClick Code | Generate or press Alt+Insert . Select the entity that you want to generate and press Enter .
JPA Buddy is a plugin for IntelliJ IDEA that makes working with JPA and related technologies easier. It provides development tools for Hibernate, EclipseLink, Spring Data JPA, Liquibase, Flyway, SQL, and similar things. JPA Buddy makes the development process easier by: introducing rich code generation capabilities.
when you generate persistence mapping, just check the below box option
匚 Show default relationships
by this to generate , you will get the table relationships you want. Hope to help you :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With