Maybe this helps:
1. the attribute is not loaded at all (no PersistentCollection creation)
1. Hibernate.isPropertyInitialized( enhancedEntity,
"extraLazyCollection" ) -> returns false
2. Hibernate.isInitialized( enhancedEntity.getExtraLazyCollection() )
-> irrelevant, the getExtraLazyCollection() call leads to creation of the
PersistentCollection (see 2.2)
2. the attribute is loaded, but the elements are not loaded
1. Hibernate.isPropertyInitialized( enhancedEntity,
"extraLazyCollection" ) -> returns true
2. Hibernate.isInitialized( enhancedEntity.getExtraLazyCollection() )
-> returns false
3. the attribute is loaded and the elements are loaded
1. Hibernate.isPropertyInitialized( enhancedEntity,
"extraLazyCollection" ) -> returns true
2. Hibernate.isInitialized( enhancedEntity.getExtraLazyCollection() )
-> returns true
IIUC you are asking whether 2.1 returning true is conceptually accurate.
Yes?
Perhaps we want to distinguish between initialized and loaded? I think
that is generally applicable.
On Thu, Mar 9, 2017 at 11:55 AM Gail Badner <gbadner(a)redhat.com> wrote:
Oops, sorry for the confusion. They should have referred to
Hibernate#isInitialized.
I'll fix and clarify below...
On Thu, Mar 9, 2017 at 4:58 AM, Steve Ebersole <steve(a)hibernate.org>
wrote:
Your subject says `Hibernate#isInitialized` but then your examples refer
to `Hibernate#initialize`. Which are your referring to? Because in some
cases you genuinely seem to be referring to `#initialize`, but then you
keep referring to its return value - `#initialize` has no return.
On Thu, Mar 9, 2017 at 12:27 AM Gail Badner <gbadner(a)redhat.com> wrote:
I think there can be an inconsistency between
Hibernate#isPropertyInitialized vs Hibernate#isInitialized when it comes to
an extra-lazy collection of an enhanced entity.
IIUC, after fixing HHH-11161 [1], if an extra-lazy collection is accessed
on an enhanced entity, the collection property is set to an uninitialized
PersistentCollection and calling Hibernate#isPropertyInitialized(
collectionfieldName ) will return true, even though the collection itself
is uninitialized.
I would have expected that false would be returned.
I've added a comment to the issue and asked Luis about it. Luis has pointed
out the 3 stages of an extra-lazy collection on an enhanced entity. I've
listed them below and added my understanding of what
Hibernate#isInitialized
and Hibernate#isPropertyInitialized will return in each instance:
1) the attribute is not loaded at all;
Hibernate.isPropertyInitialized( enhancedEntity, "extraLazyCollection"
)
returns false;
(I am skipping an example of calling Hibernate.isInitialized(
enhancedEntity.getExtraLazyCollection() )
here because by calling
enhancedEntity.getExtraLazyCollection(), the property becomes initalized
with an uninitialized PersistentCollection, so it will be in
the state described as 2).
2) the attribute is loaded, but the elements are not loaded;
Hibernate.isPropertyInitialized( enhancedEntity, "extraLazyCollection"
)
returns true,
because the property is initialized to a PersistentCollection (even
though the PersistentCollection itself is uninitialized).
Hibernate.isInitialized( enhancedEntity.getExtraLazyCollection() )
returns
false.
3) the attribute is loaded and the elements are loaded.
Hibernate.isPropertyInitialized( enhancedEntity, "extraLazyCollection" )
returns true.
Hibernate.isInitialized( enhancedEntity.getExtraLazyCollection() )
returns
true.
Opinions about the inconsistency in 2)? Is this a bug in the code or in the
Javadoc?
Thanks,
Gail
[1]
https://hibernate.atlassian.net/browse/HHH-11161
_______________________________________________
hibernate-dev mailing list
hibernate-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev