[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] EclipseLink 2.2 is calling size() on LAZY fetched OneToMany mapping Set
|
Hi Patric,
I'm a bit confused about your query. The inner select's where clause doesn't
seem to reference the object being selected in the inner select. What are you
trying to get out of this query?
-Tom
Patric Rufflar wrote:
Hi Tom,
the query is the following:
(I anonymized all names)
SELECT rev FROM MyEntity rev WHERE rev.MyEntityPK_.idPart1_ = ?1 AND
rev.MyEntityPK_.idPart2_=(SELECT MAX(rev2.MyEntityPK_.idPart2_) FROM
MyEntity rev2 WHERE rev.MyEntityPK_.idPart1_ = ?1)
MyEntity is the entity named A below
ManyToOne Mapping from MyEntity to entity B
@ManyToOne(cascade={CascadeType.PERSIST, CascadeType.MERGE,
CascadeType.REFRESH})
@JoinColumns({
@JoinColumn(name="ID_PART_1",referencedColumnName="ID_PART_1"),
@JoinColumn(name="ID_PART_2",referencedColumnName="ID_PART_2")
})
private B b_;
The OneToMany Mapping from entity B to C is:
@OneToMany(mappedBy="b_",
cascade={CascadeType.PERSIST, CascadeType.MERGE,
CascadeType.REFRESH} )
private Set<C> cSet_;
(there are other mappings defined in A and B, but I don't think that
these are relevant here)
Two Query hints are used: REFRESH = true, FLUSH = false
Pessimistic locking is not used.
Please note, that the same query, using the same entities with the same
data is not showing the problem when using EclipseLink 1.1/2.1.
Thanks,
Patric
Zitat von Tom Ware <tom.ware@xxxxxxxxxx>:
Hi Patric,
What does your query look like? What do your mappings look like?
The code that would instantiate the object runs in a couple of cases.
1. some cases where the query is doing a refresh and the relationship
was already populated in the persistence context
2. The object is joined or fetch joined in the query
3. Some pessimistic-locking related cases
-Tom
Patric Rufflar wrote:
Hi,
I encountered a situation which I cannot explain.
Maybe somebody can help me out.
I'm trying to fetch an entity of class A via Query, which has a
ManyToOne mapping to an entity
of class B which has a OneToMany mapping (using an IndirectSet) to
entities of class C.
I am not providing a FetchType, so I expect the default LAZY.
Weaving is not used.
As you can see in the stacktrace below (line marked with >>>),
EclipseLink calls size() on the
IndirectSet which causes that the actual entities of the indirection
collection will be fetched,
which of course is not desired. (in my case there are 10000 of
entities in that Set which have
additional references to other entities which causes my application
to stop working)
In EclipseLink 2.1 and 1.1.x I cannot see this behavior.
My question:
- Is this an expected behavior?
- If so: How can I force EclipseLink to not call size() on the
IndirectSet?
Thank you and best regards,
Patric
Here's the important part of the stackstrace:
...
RepeatableWriteUnitOfWork(UnitOfWorkImpl).getCommitManager() line: 1854
UnitOfWorkQueryValueHolder(UnitOfWorkValueHolder).instantiateImpl()
line: 152
UnitOfWorkQueryValueHolder(UnitOfWorkValueHolder).instantiate() line:
222
UnitOfWorkQueryValueHolder(DatabaseValueHolder).getValue() line: 88
IndirectSet.buildDelegate() line: 192
IndirectSet.getDelegate() line: 343
IndirectSet.size() line: 500
CollectionContainerPolicy.sizeFor(Object) line: 177
TransparentIndirectionPolicy.instantiateObject(Object, Object) line: 369
OneToManyMapping(ForeignReferenceMapping).buildCloneFromRow(AbstractRecord,
JoinedAttributeManager, Object, CacheKey, ObjectBuildingQuery,
UnitOfWorkImpl, AbstractSession) line: 280
ObjectBuilder.buildAttributesIntoWorkingCopyClone(Object, CacheKey,
ObjectBuildingQuery, JoinedAttributeManager, AbstractRecord,
UnitOfWorkImpl, boolean) line: 1415
ObjectBuilder.buildWorkingCopyCloneFromRow(ObjectBuildingQuery,
JoinedAttributeManager, AbstractRecord, UnitOfWorkImpl, Object) line:
1561
ObjectBuilder.buildObjectInUnitOfWork(ObjectBuildingQuery,
JoinedAttributeManager, AbstractRecord, UnitOfWorkImpl, Object,
ClassDescriptor) line: 561
ObjectBuilder.buildObject(ObjectBuildingQuery, AbstractRecord,
JoinedAttributeManager) line: 497
ObjectBuilder.buildObject(ObjectLevelReadQuery, AbstractRecord) line:
456
ReadObjectQuery(ObjectLevelReadQuery).buildObject(AbstractRecord)
line: 723
ReadObjectQuery.registerResultInUnitOfWork(Object, UnitOfWorkImpl,
AbstractRecord, boolean) line: 766
ReadObjectQuery.executeObjectLevelReadQuery() line: 451
ReadObjectQuery(ObjectLevelReadQuery).executeDatabaseQuery() line: 1080
ReadObjectQuery(DatabaseQuery).execute(AbstractSession,
AbstractRecord) line: 808
ReadObjectQuery(ObjectLevelReadQuery).execute(AbstractSession,
AbstractRecord) line: 1040
ReadObjectQuery.execute(AbstractSession, AbstractRecord) line: 412
ReadObjectQuery(ObjectLevelReadQuery).executeInUnitOfWork(UnitOfWorkImpl,
AbstractRecord) line: 1126
RepeatableWriteUnitOfWork(UnitOfWorkImpl).internalExecuteQuery(DatabaseQuery,
AbstractRecord) line: 2842
RepeatableWriteUnitOfWork(AbstractSession).executeQuery(DatabaseQuery,
AbstractRecord, int) line: 1521
RepeatableWriteUnitOfWork(AbstractSession).executeQuery(DatabaseQuery,
AbstractRecord) line: 1503
NoIndirectionPolicy.valueFromQuery(ReadQuery, AbstractRecord,
AbstractSession) line: 323
ManyToOneMapping(ForeignReferenceMapping).valueFromRowInternal(AbstractRecord,
JoinedAttributeManager, ObjectBuildingQuery, AbstractSession) line: 2061
ManyToOneMapping(OneToOneMapping).valueFromRowInternal(AbstractRecord,
JoinedAttributeManager, ObjectBuildingQuery, AbstractSession) line: 1635
ManyToOneMapping(ForeignReferenceMapping).valueFromRow(AbstractRecord,
JoinedAttributeManager, ObjectBuildingQuery, CacheKey,
AbstractSession, boolean) line: 1950
ManyToOneMapping(ForeignReferenceMapping).buildCloneFromRow(AbstractRecord,
JoinedAttributeManager, Object, CacheKey, ObjectBuildingQuery,
UnitOfWorkImpl, AbstractSession) line: 274
ObjectBuilder.buildAttributesIntoWorkingCopyClone(Object, CacheKey,
ObjectBuildingQuery, JoinedAttributeManager, AbstractRecord,
UnitOfWorkImpl, boolean) line: 1415
ObjectBuilder.buildWorkingCopyCloneFromRow(ObjectBuildingQuery,
JoinedAttributeManager, AbstractRecord, UnitOfWorkImpl, Object) line:
1561
ObjectBuilder.buildObjectInUnitOfWork(ObjectBuildingQuery,
JoinedAttributeManager, AbstractRecord, UnitOfWorkImpl, Object,
ClassDescriptor) line: 561
ObjectBuilder.buildObject(ObjectBuildingQuery, AbstractRecord,
JoinedAttributeManager) line: 497
ObjectBuilder.buildObject(ObjectLevelReadQuery, AbstractRecord) line:
456
ReadAllQuery(ObjectLevelReadQuery).buildObject(AbstractRecord) line: 723
ReadAllQuery.registerResultInUnitOfWork(Object, UnitOfWorkImpl,
AbstractRecord, boolean) line: 742
ReadAllQuery.executeObjectLevelReadQuery() line: 423
ReadAllQuery(ObjectLevelReadQuery).executeDatabaseQuery() line: 1080
ReadAllQuery(DatabaseQuery).execute(AbstractSession, AbstractRecord)
line: 808
ReadAllQuery(ObjectLevelReadQuery).execute(AbstractSession,
AbstractRecord) line: 1040
ReadAllQuery.execute(AbstractSession, AbstractRecord) line: 383
ReadAllQuery(ObjectLevelReadQuery).executeInUnitOfWork(UnitOfWorkImpl,
AbstractRecord) line: 1126
RepeatableWriteUnitOfWork(UnitOfWorkImpl).internalExecuteQuery(DatabaseQuery,
AbstractRecord) line: 2842
RepeatableWriteUnitOfWork(AbstractSession).executeQuery(DatabaseQuery,
AbstractRecord, int) line: 1521
RepeatableWriteUnitOfWork(AbstractSession).executeQuery(DatabaseQuery,
AbstractRecord) line: 1503
RepeatableWriteUnitOfWork(AbstractSession).executeQuery(DatabaseQuery,
List) line: 1477
EJBQueryImpl<X>.executeReadQuery() line: 484
EJBQueryImpl<X>.getSingleResult() line: 772
... (my application calls getSingleResult())
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users