File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Update Caos" Watch "Update Caos" New topic

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
I agree. Here's the link:
subject: Update Caos
It's not a secret anymore!