[hibernate-dev] [hibernate-orm] HHH-7572 - Develop API for load-by-multiple-ids (#1136)
Konstantin Bulanov
bulanovk at gmail.com
Mon Nov 23 03:07:11 EST 2015
Hello Steve, as you asked moving our discussion about HHH-7572 in dev mail
list.
Regarding you question, in current architecture and implementation we have
the following point to perform entity persistence customization.
Annotation:
https://docs.jboss.org/hibernate/orm/5.0/javadocs/org/hibernate/annotations/Persister.html
which allows us to specify our own implementation of
https://docs.jboss.org/hibernate/orm/5.0/javadocs/org/hibernate/persister/entity/EntityPersister.html.
One of its methods is:
Object load(Serializable id,
Object optionalObject,
LockMode lockMode,
SessionImplementor session)
throws HibernateException
Load an instance of the persistent class.
and
Object load(Serializable id,
Object optionalObject,
LockOptions lockOptions,
SessionImplementor session)
throws HibernateException
Load an instance of the persistent class.
These two methods allows to specify you own Loader implementation to load
Entity by IDS,
in mentioned issue this part of contract was ignored by changing call
sequence on loading by multiple ids.
By Single id;
org.hibernate.internal.SessionImpl#get->IdentifierLoadAccessImpl->org.hibernate.internal.SessionImpl.IdentifierLoadAccessImpl#load->org.hibernate.event.spi.LoadEventListener#onLoad->org.hibernate.event.internal.DefaultLoadEventListener#loadFromDatasource->org.hibernate.persister.entity.EntityPersister#load
By Multiple id:
org.hibernate.internal.SessionImpl#byMultipleIds->org.hibernate.internal.SessionImpl.MultiIdentifierLoadAccessImpl#multiLoad->org.hibernate.loader.entity.DynamicBatchingEntityLoaderBuilder#multiLoad
So in new API for multiple load we lose at least 2 possible extension
points: onLoadEvent, Persister.load (here we could customize loader -
specify our own instead hardcoded one)
>From my point of view there should be the same approach to get entities by
ID(independent multiple or single).
So which one approach is correct and future-proof for Single id or Multiple
Ids?
20 нояб. 2015 г. 18:19 пользователь "Steve Ebersole" <
notifications at github.com> написал:
> Customize how? Loader still calls into the persister. Persisters and
> Loaders have a back-and-forth synergy.
>
> Also please discuss this on the hibernate-dev mailing list so others can be
> involved.
>
> On Fri, Nov 20, 2015 at 7:15 AM Konstantin Bulanov <
> notifications at github.com>
> wrote:
>
> > Hello Steve, could you be so kind to advice why we have different
> behavior
> > for loading by single id and multiple ids?
> >
> > In Case of single id, loading is going through
> > session->IdentifierLoadAccess->event->persister->Loader
> > In Case of multiple ids, loading is going through
> > session->MultiIdentifierLoadAccess->Loader
> >
> > So in case of load by single id it is possible to cutomize loading of
> > Entify using persister, but in new introduced API we lost this
> posibility.
> >
> > —
> > Reply to this email directly or view it on GitHub
> > <
> https://github.com/hibernate/hibernate-orm/pull/1136#issuecomment-158400273
> >
> > .
> >
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/hibernate/hibernate-orm/pull/1136#issuecomment-158413356>
> .
>
More information about the hibernate-dev
mailing list