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?
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.