Community
Participate
Working Groups
Build Identifier: 2.2.0-RC3 After debugging I've figured out that when using a session.copy on an object with a lazily fetched collection (IndirectionList) it materializes the collection. After more digging, it looks like when it is attempting to copy the list it creates an Iterator for the mapping to iterate and copy over (ObjectBuilder line 2061). The problem then stems from the population of the delegate object in IndirectList line 397 where it's actually pulling the data from the database. I would imagine that it should really just be copying and registering a new IndirectionList without trying to pull in the data. For example, I might have an object with many objects in a lazy loaded collection, and if it hasn't been materialized yet, then why should copying force it to do so? That could result in a very slow operation if I had a large number of records loaded (which were never used so far). That's just my opinion on the matter! So my fix would be to check if (CollectionMapping buildCopy line 236) attributeValue instanceof IndirectionList && (IndirectionList)attributeValue.isInstantiated() before proceeding with the getting of an iterator and copying the values. Then I would imagine some work has to be done to create a copy of the indirection list so both the copy and the original object have lazily loaded collections. Reproducible: Always Steps to Reproduce: 1. Call entityManager.getServerSession().copy(object) where object is an Entity with a lazily loaded list. 2. The list will then be populated.
>this issue is also related to bug # 333316 where instantiation of a lazy (IndirectList) occurs during debugging - because of an inherent toString() that happened to deep inspect @OneToMany relationships http://bugs.eclipse.org/333316 However in that case the bidirectional had mixed EAGER and LAZY FetchType(s)
Setting target and priority. See the following page for the meanings of these fields: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines
Created attachment 195855 [details] proposed-patch
Investigating
Note: org.eclipse.persistence.sessions.CopyGroup can now be used to define the level to which you want to copy an object.
Closing. The copy functionality is designed to copy the whole object including unloaded portions of relationships. Use our copygroup functionality to get parts of the object.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink