Author: epbernard
Date: 2007-03-01 12:52:59 -0500 (Thu, 01 Mar 2007)
New Revision: 11250
Modified:
branches/Branch_3_2/HibernateExt/search/src/java/org/hibernate/search/impl/FullTextSessionImpl.java
Log:
HSEARCH-25 never cast to SessionImpl since Hibernate wrap the session sometimes. Bad me
Modified:
branches/Branch_3_2/HibernateExt/search/src/java/org/hibernate/search/impl/FullTextSessionImpl.java
===================================================================
---
branches/Branch_3_2/HibernateExt/search/src/java/org/hibernate/search/impl/FullTextSessionImpl.java 2007-03-01
08:29:34 UTC (rev 11249)
+++
branches/Branch_3_2/HibernateExt/search/src/java/org/hibernate/search/impl/FullTextSessionImpl.java 2007-03-01
17:52:59 UTC (rev 11250)
@@ -7,55 +7,48 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
-import javax.transaction.Status;
-
+import org.apache.lucene.document.Document;
import org.hibernate.CacheMode;
import org.hibernate.Criteria;
import org.hibernate.EntityMode;
import org.hibernate.Filter;
import org.hibernate.FlushMode;
+import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
+import org.hibernate.Interceptor;
import org.hibernate.LockMode;
import org.hibernate.Query;
import org.hibernate.ReplicationMode;
import org.hibernate.SQLQuery;
-import org.hibernate.Session;
+import org.hibernate.ScrollMode;
+import org.hibernate.ScrollableResults;
+import org.hibernate.classic.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
-import org.hibernate.Interceptor;
-import org.hibernate.ScrollableResults;
-import org.hibernate.ScrollMode;
-import org.hibernate.Hibernate;
-import org.hibernate.event.EventListeners;
-import org.hibernate.loader.custom.CustomQuery;
-import org.hibernate.persister.entity.EntityPersister;
-import org.hibernate.jdbc.Batcher;
-import org.hibernate.jdbc.JDBCContext;
import org.hibernate.collection.PersistentCollection;
-import org.hibernate.engine.query.ParameterMetadata;
-import org.hibernate.engine.query.sql.NativeSQLQuerySpecification;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.engine.QueryParameters;
import org.hibernate.engine.EntityKey;
import org.hibernate.engine.PersistenceContext;
-import org.hibernate.impl.SessionImpl;
+import org.hibernate.engine.QueryParameters;
+import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.engine.SessionImplementor;
+import org.hibernate.engine.query.ParameterMetadata;
+import org.hibernate.engine.query.sql.NativeSQLQuerySpecification;
+import org.hibernate.event.EventListeners;
+import org.hibernate.event.EventSource;
import org.hibernate.impl.CriteriaImpl;
-import org.hibernate.search.query.FullTextQueryImpl;
-import org.hibernate.search.util.ContextHelper;
-import org.hibernate.search.engine.DocumentBuilder;
+import org.hibernate.jdbc.Batcher;
+import org.hibernate.jdbc.JDBCContext;
+import org.hibernate.loader.custom.CustomQuery;
+import org.hibernate.persister.entity.EntityPersister;
+import org.hibernate.search.FullTextSession;
import org.hibernate.search.SearchFactory;
import org.hibernate.search.backend.UpdateWork;
-import org.hibernate.search.backend.Work;
-import org.hibernate.search.backend.QueueingProcessor;
-import org.hibernate.search.backend.impl.BatchedQueueingProcessor;
-import org.hibernate.search.backend.impl.PostTransactionWorkQueueSynchronization;
-import org.hibernate.search.FullTextSession;
+import org.hibernate.search.engine.DocumentBuilder;
+import org.hibernate.search.query.FullTextQueryImpl;
+import org.hibernate.search.util.ContextHelper;
import org.hibernate.stat.SessionStatistics;
import org.hibernate.type.Type;
-import org.apache.lucene.document.Document;
/**
* Lucene Full text search aware session
@@ -63,11 +56,14 @@
* @author Emmanuel Bernard
*/
public class FullTextSessionImpl implements FullTextSession, SessionImplementor {
- private final SessionImpl session;
- private PostTransactionWorkQueueSynchronization postTransactionWorkQueueSynch;
+ private final Session session;
+ private final EventSource eventSource;
+ private final SessionImplementor sessionImplementor;
- public FullTextSessionImpl(Session session) {
- this.session = (SessionImpl) session;
+ public FullTextSessionImpl(org.hibernate.Session session) {
+ this.session = (Session) session;
+ this.eventSource = (EventSource) session;
+ this.sessionImplementor = (SessionImplementor) session;
}
/**
@@ -77,7 +73,7 @@
* @param entities must be immutable for the lifetime of the query object
*/
public Query createFullTextQuery(org.apache.lucene.search.Query luceneQuery, Class...
entities) {
- return new FullTextQueryImpl( luceneQuery, entities, session, new
ParameterMetadata(null, null) );
+ return new FullTextQueryImpl( luceneQuery, entities, sessionImplementor, new
ParameterMetadata(null, null) );
}
/**
@@ -96,7 +92,7 @@
Serializable id = session.getIdentifier( entity );
Document doc = builder.getDocument( entity, id );
UpdateWork work = new UpdateWork( id, entity.getClass(), doc );
- searchFactory.getWorker().performWork( work, session );
+ searchFactory.getWorker().performWork( work, eventSource );
}
//TODO
//need to add elements in a queue kept at the Session level
@@ -204,9 +200,7 @@
}
public void clear() {
- if (postTransactionWorkQueueSynch != null &&
!postTransactionWorkQueueSynch.isConsumed() ) {
- postTransactionWorkQueueSynch.afterCompletion( Status.STATUS_ROLLEDBACK );
- }
+ //FIXME should session clear work with the lucene queue
session.clear();
}
@@ -307,153 +301,153 @@
}
public Interceptor getInterceptor() {
- return session.getInterceptor();
+ return sessionImplementor.getInterceptor();
}
public void setAutoClear(boolean enabled) {
- session.setAutoClear( enabled );
+ sessionImplementor.setAutoClear( enabled );
}
public boolean isTransactionInProgress() {
- return session.isTransactionInProgress();
+ return sessionImplementor.isTransactionInProgress();
}
public void initializeCollection(PersistentCollection collection, boolean writing)
throws HibernateException {
- session.initializeCollection( collection, writing );
+ sessionImplementor.initializeCollection( collection, writing );
}
public Object internalLoad(String entityName, Serializable id, boolean eager, boolean
nullable)
throws HibernateException {
- return session.internalLoad( entityName, id, eager, nullable );
+ return sessionImplementor.internalLoad( entityName, id, eager, nullable );
}
public Object immediateLoad(String entityName, Serializable id) throws
HibernateException {
- return session.immediateLoad( entityName, id );
+ return sessionImplementor.immediateLoad( entityName, id );
}
public long getTimestamp() {
- return session.getTimestamp();
+ return sessionImplementor.getTimestamp();
}
public SessionFactoryImplementor getFactory() {
- return session.getFactory();
+ return sessionImplementor.getFactory();
}
public Batcher getBatcher() {
- return session.getBatcher();
+ return sessionImplementor.getBatcher();
}
public List list(String query, QueryParameters queryParameters) throws
HibernateException {
- return session.list( query, queryParameters );
+ return sessionImplementor.list( query, queryParameters );
}
public Iterator iterate(String query, QueryParameters queryParameters) throws
HibernateException {
- return session.iterate( query, queryParameters );
+ return sessionImplementor.iterate( query, queryParameters );
}
public ScrollableResults scroll(String query, QueryParameters queryParameters) throws
HibernateException {
- return session.scroll( query, queryParameters );
+ return sessionImplementor.scroll( query, queryParameters );
}
public ScrollableResults scroll(CriteriaImpl criteria, ScrollMode scrollMode) {
- return session.scroll( criteria, scrollMode );
+ return sessionImplementor.scroll( criteria, scrollMode );
}
public List list(CriteriaImpl criteria) {
- return session.list( criteria );
+ return sessionImplementor.list( criteria );
}
public List listFilter(Object collection, String filter, QueryParameters
queryParameters)
throws HibernateException {
- return session.listFilter( collection, filter, queryParameters );
+ return sessionImplementor.listFilter( collection, filter, queryParameters );
}
public Iterator iterateFilter(Object collection, String filter, QueryParameters
queryParameters)
throws HibernateException {
- return session.iterateFilter( collection, filter, queryParameters );
+ return sessionImplementor.iterateFilter( collection, filter, queryParameters );
}
public EntityPersister getEntityPersister(String entityName, Object object) throws
HibernateException {
- return session.getEntityPersister( entityName, object );
+ return sessionImplementor.getEntityPersister( entityName, object );
}
public Object getEntityUsingInterceptor(EntityKey key) throws HibernateException {
- return session.getEntityUsingInterceptor( key );
+ return sessionImplementor.getEntityUsingInterceptor( key );
}
public void afterTransactionCompletion(boolean successful, Transaction tx) {
- session.afterTransactionCompletion( successful, tx );
+ sessionImplementor.afterTransactionCompletion( successful, tx );
}
public void beforeTransactionCompletion(Transaction tx) {
- session.beforeTransactionCompletion( tx );
+ sessionImplementor.beforeTransactionCompletion( tx );
}
public Serializable getContextEntityIdentifier(Object object) {
- return session.getContextEntityIdentifier( object );
+ return sessionImplementor.getContextEntityIdentifier( object );
}
public String bestGuessEntityName(Object object) {
- return session.bestGuessEntityName( object );
+ return sessionImplementor.bestGuessEntityName( object );
}
public String guessEntityName(Object entity) throws HibernateException {
- return session.guessEntityName( entity );
+ return sessionImplementor.guessEntityName( entity );
}
public Object instantiate(String entityName, Serializable id) throws HibernateException
{
- return session.instantiate( entityName, id );
+ return sessionImplementor.instantiate( entityName, id );
}
public List listCustomQuery(CustomQuery customQuery, QueryParameters queryParameters)
throws HibernateException {
- return session.listCustomQuery( customQuery, queryParameters );
+ return sessionImplementor.listCustomQuery( customQuery, queryParameters );
}
public ScrollableResults scrollCustomQuery(CustomQuery customQuery, QueryParameters
queryParameters)
throws HibernateException {
- return session.scrollCustomQuery( customQuery, queryParameters );
+ return sessionImplementor.scrollCustomQuery( customQuery, queryParameters );
}
public List list(NativeSQLQuerySpecification spec, QueryParameters queryParameters)
throws HibernateException {
- return session.list( spec, queryParameters );
+ return sessionImplementor.list( spec, queryParameters );
}
public ScrollableResults scroll(NativeSQLQuerySpecification spec, QueryParameters
queryParameters)
throws HibernateException {
- return session.scroll( spec, queryParameters );
+ return sessionImplementor.scroll( spec, queryParameters );
}
public Object getFilterParameterValue(String filterParameterName) {
- return session.getFilterParameterValue( filterParameterName );
+ return sessionImplementor.getFilterParameterValue( filterParameterName );
}
public Type getFilterParameterType(String filterParameterName) {
- return session.getFilterParameterType( filterParameterName );
+ return sessionImplementor.getFilterParameterType( filterParameterName );
}
public Map getEnabledFilters() {
- return session.getEnabledFilters();
+ return sessionImplementor.getEnabledFilters();
}
public int getDontFlushFromFind() {
- return session.getDontFlushFromFind();
+ return sessionImplementor.getDontFlushFromFind();
}
public EventListeners getListeners() {
- return session.getListeners();
+ return sessionImplementor.getListeners();
}
public PersistenceContext getPersistenceContext() {
- return session.getPersistenceContext();
+ return sessionImplementor.getPersistenceContext();
}
public int executeUpdate(String query, QueryParameters queryParameters) throws
HibernateException {
- return session.executeUpdate( query, queryParameters );
+ return sessionImplementor.executeUpdate( query, queryParameters );
}
public int executeNativeUpdate(NativeSQLQuerySpecification specification,
QueryParameters queryParameters)
throws HibernateException {
- return session.executeNativeUpdate( specification, queryParameters );
+ return sessionImplementor.executeNativeUpdate( specification, queryParameters );
}
public EntityMode getEntityMode() {
@@ -477,31 +471,31 @@
}
public Query getNamedSQLQuery(String name) {
- return session.getNamedSQLQuery( name );
+ return sessionImplementor.getNamedSQLQuery( name );
}
public boolean isEventSource() {
- return session.isEventSource();
+ return sessionImplementor.isEventSource();
}
public void afterScrollOperation() {
- session.afterScrollOperation();
+ sessionImplementor.afterScrollOperation();
}
public void setFetchProfile(String name) {
- session.setFetchProfile( name );
+ sessionImplementor.setFetchProfile( name );
}
public String getFetchProfile() {
- return session.getFetchProfile();
+ return sessionImplementor.getFetchProfile();
}
public JDBCContext getJDBCContext() {
- return session.getJDBCContext();
+ return sessionImplementor.getJDBCContext();
}
public boolean isClosed() {
- return session.isClosed();
+ return sessionImplementor.isClosed();
}
public org.hibernate.Session getSession(EntityMode entityMode) {