Reputation: 1
table A: subsId transId
table B: transId, itemId
table C: transId, payId
table D: payId, taxId
Table join: A.transId=B.transId, A.transId=C.transId, C.payId=D.taxId
A:B is a 1:many relation
A:C is a 1:1 relation
C:D is a 1:1 relation
Im using SQL to query these four tables and persisting the result in a pojo X.
pojo definition:
@Entity
public class X implements Serializable{
private String transId;
@Id
private String itemid;
private String payId;
private String taxId;
private String subsId;
}
I dont understand the hibernate annotation mappings to use at all. I am horribly confused between JoinTables, JoinColumns, OneToMany, ManyToOne, OneToOne annotations. Can you suggest the annotations?
Upvotes: 0
Views: 184
Reputation: 16452
With JPA/Hibernate you create a persistence model that reflects your database model in the object world. I don't fully know your schema, but here is a nice explanation about JPA mappings: https://en.wikibooks.org/wiki/Java_Persistence/Relationships
Upvotes: 1