[hibernate-dev] Storing values at the session level

Sanne Grinovero sanne at hibernate.org
Mon Mar 10 11:24:57 EDT 2014

This seems like related to the relation-walking optimization we
discussed for Neo4J: also would need to couple the entity instance to
the Neo4J document. Currently the Neo4J griddialect would need to run
a new query for a graph-traversal: not taking advantage of the graph
capabilities which is of course a problem.

In Hibernate ORM the EntityEntry stores an array with the loaded
values from SQL, needed for some of its state handling. I'd say we
should have a way to store data related to extension points into this

If we made this as a general purpose enhancement of ORM, we could
maybe have it abstract the storage of the additional attributes into,
for example, the enhanced entity class definitions: it would add a
field directly to the Entity instance for you to store such an object.
There where some chats about maybe doing such an optimization anyway,
driven by the performance work.


On 10 March 2014 12:32, Gunnar Morling <gunnar at hibernate.org> wrote:
> Minor correction:
>> Unfortunately there is no getter for the session owner on
> SessionFactoryImplementor
> s/SessionFactoryImplementor/SessionImplementor
> --Gunnar
> 2014-03-10 12:59 GMT+01:00 Gunnar Morling <gunnar at hibernate.org>:
>> Hi,
>> I'm looking into ways for reducing the number of datastore roundtrips in
>> OGM [1].
>> One idea is to fetch associations embedded within entity documents (e.g.
>> in MongoDB) when loading such document. We'd "remember" the entity document
>> and could later on retrieve the association from it without going to the
>> store a second time.
>> The problem is the "remembering" part. There is no session-scoped storage
>> facility as of today which I could use. I contemplated making OgmSession
>> deal with this, but I can't access that from persisters etc. Instead I'm
>> seeing the wrapped SessionImpl (to which OgmSession delegates for many
>> operations) and I couldn't find a way to reach the wrapping OgmSession
>> instance.
>> Now I noticed the concept of "SessionOwner" in SessionImpl and am
>> wondering whether I could make use of this. When creating the SessionImpl,
>> I could pass the OgmSession as owner and have it maintain a session-scoped
>> storage. Unfortunately there is no getter for the session owner on
>> SessionFactoryImplementor, though.
>> Would it be feasible to add this getter and thus make a session's owner
>> accessible? Or is there any other (better) way to achieve what I described?
>> Many thanks,
>> --Gunnar
>> [1] https://hibernate.atlassian.net/browse/OGM-469
> _______________________________________________
> 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