That's exactly what i thought but with jpa i got the exception "hibernate session is closed".
I got the mysql pool at JBoss 6 and I inject the code in my EJB 3.0 with:
@PersistenceContext()
EntityManager
em;
My example with
JPA:
FullTextEntityManager fullTextEntityManager = org.hibernate.search.jpa.Search.getFullTextEntityManager(
em);
final QueryBuilder b = fullTextEntityManager.getSearchFactory().buildQueryBuilder().forEntity( Myth.class ).get();
org.apache.lucene.search.Query luceneQuery = b.keyword().onField("history").boostedTo(3).matching("storm").createQuery();
javax.persistence.Query fullTextQuery = fullTextEntityManager.createFullTextQuery( luceneQuery );
List result = fullTextQuery.getResultList(); //return a list of managed objects
My example with
Hibernate Session:
Session session = (Session) em.unwrap(Session.class);
FullTextSession fullTextSession = Search.getFullTextSession(session);
SearchFactory searchFactory = fullTextSession.getSearchFactory();
...
org.hibernate.Query fullTextQuery = fullTextSession.createFullTextQuery(luceneQuery);
List result = fullTextQuery.list(); //return a list of managed objects
It's like with JPA the Hibernate Session is never initialized..but I don't really know. I' ve got an example that works with Hibernate session. You can check it out at
http://forum.hibernate.org/viewtopic.php?f=9&t=1011450.
With JPA, should i start the session? I think that the EJB does it for me....
Well, let me know any suggestions :)
Thanks in advance.