-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Hibernate Search and the Spring Framework
PostPosted: Tue Jan 15, 2008 12:41 am 
Newbie

Joined: Tue Jan 15, 2008 12:18 am
Posts: 3
We are integrating Hibernate Search (3.0.0 GA) into an existing Hibernate / Spring Framework / Eclipse RCP configuration. Unfortunately, Hibernate Search's FullTextSessionImpl assumes that it will be passed an org.hibernate.classic.Session. When using Spring for Hibernate transaction management, Spring creates a defensive Proxy that disables the Session.close() method. This Proxy does not implement the EventSource nor classic.Session, while Hibernate Search assumes that it does and has a ClassCastException in the FullTextSessionImpl constructor.

Hibernate Search's FullTextSessionImpl does this which is wrong for the Spring Hibernate Session Proxy:

public FullTextSessionImpl(org.hibernate.Session session) {
this.session = (Session) session; // classic.Session!
this.eventSource = (EventSource) session;
this.sessionImplementor = (SessionImplementor) session;
}

It should be possible to rewrite FullTextSession and FullTextSessionImpl so that they do not use the org.hibernate.classic.Session but instead use the standard Hibernate Session, and thus avoid the unsafe casting.

The workaround for this is to use HibernateTemplate.setExposeNativeSession( true ) before executing the HibernateCallback (causing the SessionImpl to be passed directly, without a Proxy). This exposes the Session to potential close() and is *not* a good idea.


I've filed this as a bug here:
http://opensource.atlassian.com/project ... SEARCH-148

And I'm posting to these forums so that people can easily google search this on site:hibernate.org

If anyone has experience integrating Hibernate Search with Spring transaction management, please chime in. Cheers.

_________________
Michael Lossos
Software Goodness Limited
http://www.softwaregoodness.com/


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 15, 2008 8:27 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
No Hibernate Search has to have access to EventSource (actually SessionImplementor) because it plays with the transaction state.
so really Spring should implements all the necessary interfaces in their wrapper proxy.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 15, 2008 9:23 pm 
Newbie

Joined: Tue Jan 15, 2008 12:18 am
Posts: 3
Thanks emmanuel for the prompt reply! And thank you very much for all the hard work you've put into Hibernate Search and these forums!

If the FullTextSessionImpl requires a org.hibernate.classic.Session and EventSource, shouldn't it take those as parameters to the constructor (and Search.createFullTextSession should too)? What's there right now with the unsafe downcasting explodes at runtime instead of being enforced at compile time...

I've filed a bug with the Spring framework to have their proxy implement the additional interfaces needed by Hibernate Search:
http://jira.springframework.org/browse/SPR-4341

_________________
Michael Lossos
Software Goodness Limited
http://www.softwaregoodness.com/


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 17, 2008 2:47 pm 
Newbie

Joined: Sun Mar 16, 2008 6:39 pm
Posts: 4
According to the JIRA report this problem has been addressed in spring 2.5.2


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.