Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 349
user1462933 Avatar asked Mar 24 '13 01:03

user1462933


People also ask

How do I generate entities from an existing database in IntelliJ?

Generate a database entityClick Code | Generate or press Alt+Insert . Select the entity that you want to generate and press Enter .

What is JPA buddy?

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.


1 Answers

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

like image 63
Hunter Zhao Avatar answered Nov 15 '22 05:11

Hunter Zhao