Search code examples
sql-server-2008jsf-2intellij-ideamappingopenjpa

intellij idea, generating persistence mapping with relationships


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.


Solution

  • 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 :)

    enter image description here