![]() You probably expected that Hibernate would only persist a new Item entity in the item table. Items0_.PurchaseOrder_id as Purchase1_2_0_, class PurchaseOrder Set items = new HashSet() īut take a look at the SQL statements Hibernate executes when you persist a new Item entity and add it to the one-to-many association. You just need an attribute that maps the association and a relationship. The definition of an unidirectional one-to-many association doesn’t seem to be an issue. Let’s take a closer look at the standard mapping. Otherwise, Hibernate might create unexpected tables and execute more SQL statements than you expected. But you should avoid unidirectional one-to-many associations in your domain model. 6 Define FetchType.LAZY for associationĭon’t use unidirectional one-to-many associationsīidirectional one-to-many and both many-to-one association mappings are fine.5 Implement helper methods to update bi-directional associations.4 Use orphanRemoval when modeling parent-child associations.3 Think twice before using CascadeType.Remove. ![]()
0 Comments
Leave a Reply. |