[hibernate-dev] persister.afterInitialize() called too early

Steve Ebersole steve at hibernate.org
Mon Oct 15 09:28:04 EDT 2018


The collection should be added to the persistence context as soon as
`CollectionType#resolve` is called, so this is interesting.


On Mon, Oct 15, 2018 at 5:49 AM Guillaume Smet <guillaume.smet at gmail.com>
wrote:

> Hi,
>
> On Friday, I started to take a look at
> https://hibernate.atlassian.net/browse/HHH-12425.
>
> The current flow of operations is the following:
> Loader#initializeEntitiesAndCollections
>  \_ TwoPhaseLoad.initializeEntity()
>       \_ initialize the entity
>       \_ persister.afterInitialize()
>  \_ endCollectionLoad of the collection persisters
>  \_ TwoPhaseLoad.postLoad()
>
> The issue we have is that afterInitialize() is called before the collection
> loading has been done. The collections are not in the persistence context
> yet when calling persister.afterInitialize(), which is required with
> enhanced entities.
>
> As afterInitialize() is supposed to be called after the properties have
> been initialized, I think it makes sense to wait for the collections to be
> properly initialized.
>
> I'm wondering if we should isolate the persister.afterInitialize() call
> into a TwoPhaseLoad.afterInitialize() method, which would be called after
> the collection initialization.
>
> Any thoughts or better ideas?
>
> Thanks.
>
> --
> Guillaume
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>


More information about the hibernate-dev mailing list