Hibernate.getImplementation(Object)
by Emmanuel Bernard
For Hibernate Search I came to a problem.
When a user choose field access.
When I access a previously uninitialized object, and even if I
initialize it (Hibernate.initialize()).
The field access End up returning null all the time because of the
way lazy loading is done. I worked around that using some of the code
from Hibernate.initialize()
if ( value instanceof HibernateProxy ) {
value = ( ( HibernateProxy ) value ).getHibernateLazyInitializer()
.getImplementation();
}
But it seems it really should be part of the Hibernate class contract.
I could use
Hibernate.initialize(value);
value = session.get( Hibernate.getClass(value),
session.getIdentifier(value) );
but at the present time, it's hard for me to access the session, and
conceptually speaking there is no real need for it.
How about exposing this service in Hibernate class either
value = Hibernate.initialize(value); //changing the return value
or
value = Hibernate.getImplementation(value);
WDYT?
17 years, 6 months
IndexReader caching second pair of eyes
by Emmanuel Bernard
For Hibernate Search, I did introduce the IndexReaders caching.
My tests shows for:
- a search intensive application,
- low update ratio
- in-memory database
- filesystem based index
a speed increase of 25 to 30%.
It is not the default yet (use 'hibernate.search.reader.strategy
shared' to enable), but once it's tested, it will be.
It was not a piece of cake (to say the least), I would appreciate a
couple of pairs of eyes on the code, as it involves locking and JMM
understanding.
I think I reduced the lock windows as much as possible but if
someone's got ideas (or think it's unsafe), fell free to share.
The code is here
http://fisheye.jboss.org/browse/Hibernate/trunk/HibernateExt/search/
src/java/org/hibernate/search/reader/SharedReaderProvider.java?r=11576
17 years, 6 months