Last Updated on: (senast uppdaterad på:)
Although one or two tutorials can lead to the answer in how to write code for entities that hold bidirectional relationship, here is a suggest set of links and descriptions that can help:
- Start with a Database design that holds two related tables: Orders and Order Lines. What is an order-line:
https://stackoverflow.com/questions/10367206/what-is-a-order-line#10367237 - Take a look at the tutorial that shows a JPA – Bidirectional OneToMany/ManyToOne Example:
https://www.logicbig.com/tutorials/java-ee-tutorial/jpa/one-to-many-bidirectional.html - While describing other related patterns such as DAO, read a blog series that continues with a tutorial on JPA implementation patterns — Bidirectional associations:
https://xebia.com/blog/jpa-implementation-patterns-bidirectional-assocations/
Other resources through out the development (in a more or less orderly list of suggested readings):
- JPA – Entity Managers
https://www.tutorialspoint.com/jpa/jpa_entity_managers.htm - DAO:
https://xebia.com/blog/jpa-implementation-patterns-data-access-objects/ - Storing JPA Entity Objects
https://www.objectdb.com/java/jpa/persistence/store#Cascading_Persist - JPA implementation patterns: Data Access Objects
https://xebia.com/blog/jpa-implementation-patterns-data-access-objects/ - Hibernate – One-to-Many example (Annotation)
https://www.mkyong.com/hibernate/hibernate-one-to-many-relationship-example-annotation/
Related Questions:
- JPA/Hibernate: detached entity passed to persist
https://stackoverflow.com/questions/13370221/jpa-hibernate-detached-entity-passed-to-persist#29235227 - Hibernate Example for Id column
https://stackoverflow.com/questions/5051060/hibernate-example-for-id-column - Change the Entity ID name in JPA
https://stackoverflow.com/questions/42537663/change-the-entity-id-name-in-jpa - Java hibernate Unknown column ‘ ‘ in ‘field list’
https://stackoverflow.com/questions/15066227/java-hibernate-unknown-column-in-field-list