This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Update Caos Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Update Caos" Watch "Update Caos" New topic
Author

Update Caos

Jorge Bendahan
Ranch Hand

Joined: Apr 11, 2008
Posts: 82
Hi all, I have an object "A" than contains a Collection of objects "B" and a collection of objects "C". Every time i merge an atribute of A, i noticed that the persistence provider creates a lots of select statements, it´s getting really slow. I have tried the following:

Change from this


to this


but i cannot tell the difference.
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
What is your provider, and what are the SQL statements?

In JPA merge will always merge references, but only cascade the merge to the related objects if set to cascade. i.e. the collection will always be merged, but the objects in the collection will only be merged if cascading. There is no way in JPA to not merge the collection references, (unless it is lazy and not instantiated), other than manually merging the objects. If you are using EclipseLink the EclipseLink API also provides a shallowMerge and a merge without references.

TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
 
Consider Paul's rocket mass heater.
 
subject: Update Caos
 
Similar Threads
JPA: Cascade delete for join tables with composite key
Can not remove a EJB 3 entity and the error is: violation of foreign key constraint
can i mark a Set/Collection porpety as @Id
JPA composite key mapping
Can't map to target entity property