Author: epbernard
Date: 2010-01-05 05:53:42 -0500 (Tue, 05 Jan 2010)
New Revision: 18409
Modified:
search/trunk/pom.xml
search/trunk/src/main/java/org/hibernate/search/impl/FullTextSessionImpl.java
search/trunk/src/main/java/org/hibernate/search/query/FullTextQueryImpl.java
search/trunk/src/test/java/org/hibernate/search/test/session/SessionTest.java
Log:
HSEARCH-437 Add test to theadbound session wrapped out of transaction
Implement latest version of the Session Query interfaces
use latest snapshot
Modified: search/trunk/pom.xml
===================================================================
--- search/trunk/pom.xml 2010-01-05 10:46:13 UTC (rev 18408)
+++ search/trunk/pom.xml 2010-01-05 10:53:42 UTC (rev 18409)
@@ -58,7 +58,7 @@
<properties>
<slf4jVersion>1.5.8</slf4jVersion>
<luceneVersion>2.4.1</luceneVersion>
- <hibernateVersion>3.5.0-Beta-2</hibernateVersion>
+ <hibernateVersion>3.5.0-SNAPSHOT</hibernateVersion>
<hibernateCommonsAnnotationVersion>3.2.0.Beta1</hibernateCommonsAnnotationVersion>
</properties>
Modified: search/trunk/src/main/java/org/hibernate/search/impl/FullTextSessionImpl.java
===================================================================
---
search/trunk/src/main/java/org/hibernate/search/impl/FullTextSessionImpl.java 2010-01-05
10:46:13 UTC (rev 18408)
+++
search/trunk/src/main/java/org/hibernate/search/impl/FullTextSessionImpl.java 2010-01-05
10:53:42 UTC (rev 18409)
@@ -49,6 +49,7 @@
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.UnknownProfileException;
+import org.hibernate.LockOptions;
import org.hibernate.classic.Session;
import org.hibernate.collection.PersistentCollection;
import org.hibernate.engine.EntityKey;
@@ -57,6 +58,7 @@
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.engine.LoadQueryInfluencers;
+import org.hibernate.engine.NonFlushedChanges;
import org.hibernate.engine.query.ParameterMetadata;
import org.hibernate.engine.query.sql.NativeSQLQuerySpecification;
import org.hibernate.event.EventListeners;
@@ -386,6 +388,10 @@
return session.get( clazz, id, lockMode );
}
+ public Object get(Class clazz, Serializable id, LockOptions lockOptions) throws
HibernateException {
+ return session.get(clazz, id, lockOptions);
+ }
+
public Object get(String entityName, Serializable id) throws HibernateException {
return session.get( entityName, id );
}
@@ -394,6 +400,10 @@
return session.get( entityName, id, lockMode );
}
+ public Object get(String entityName, Serializable id, LockOptions lockOptions) throws
HibernateException {
+ return session.get(entityName, id, lockOptions);
+ }
+
public CacheMode getCacheMode() {
return session.getCacheMode();
}
@@ -556,6 +566,14 @@
return sessionImplementor.executeNativeUpdate( specification, queryParameters );
}
+ public NonFlushedChanges getNonFlushedChanges() throws HibernateException {
+ return sessionImplementor.getNonFlushedChanges();
+ }
+
+ public void applyNonFlushedChanges(NonFlushedChanges nonFlushedChanges) throws
HibernateException {
+ sessionImplementor.applyNonFlushedChanges( nonFlushedChanges );
+ }
+
public EntityMode getEntityMode() {
return session.getEntityMode();
}
@@ -644,6 +662,10 @@
return session.load( entityName, id, lockMode );
}
+ public Object load(String entityName, Serializable id, LockOptions lockOptions) throws
HibernateException {
+ return session.load( entityName, id, lockOptions );
+ }
+
public void load(Object object, Serializable id) throws HibernateException {
session.load( object, id );
}
@@ -656,10 +678,18 @@
return session.load( theClass, id, lockMode );
}
+ public Object load(Class theClass, Serializable id, LockOptions lockOptions) throws
HibernateException {
+ return session.load( theClass, id, lockOptions );
+ }
+
public void lock(String entityName, Object object, LockMode lockMode) throws
HibernateException {
session.lock( entityName, object, lockMode );
}
+ public LockRequest buildLockRequest(LockOptions lockOptions) {
+ return session.buildLockRequest( lockOptions );
+ }
+
public void lock(Object object, LockMode lockMode) throws HibernateException {
session.lock( object, lockMode );
}
@@ -696,6 +726,10 @@
session.refresh( object, lockMode );
}
+ public void refresh(Object object, LockOptions lockOptions) throws HibernateException {
+ session.refresh( object, lockOptions );
+ }
+
public void replicate(String entityName, Object object, ReplicationMode replicationMode)
throws HibernateException {
session.replicate( entityName, object, replicationMode );
}
Modified: search/trunk/src/main/java/org/hibernate/search/query/FullTextQueryImpl.java
===================================================================
---
search/trunk/src/main/java/org/hibernate/search/query/FullTextQueryImpl.java 2010-01-05
10:46:13 UTC (rev 18408)
+++
search/trunk/src/main/java/org/hibernate/search/query/FullTextQueryImpl.java 2010-01-05
10:53:42 UTC (rev 18409)
@@ -57,6 +57,7 @@
import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults;
import org.hibernate.Session;
+import org.hibernate.LockOptions;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.engine.query.ParameterMetadata;
import org.hibernate.impl.AbstractQueryImpl;
@@ -877,6 +878,10 @@
return this;
}
+ public Query setLockOptions(LockOptions lockOptions) {
+ throw new UnsupportedOperationException( "Lock options are not implemented in
Hibernate Search queries");
+ }
+
@Override
public FullTextQuery setResultTransformer(ResultTransformer transformer) {
super.setResultTransformer( transformer );
@@ -884,6 +889,10 @@
return this;
}
+ protected LockOptions getLockOptions() {
+ return null;
+ }
+
public int executeUpdate() throws HibernateException {
throw new HibernateException( "Not supported operation" );
}
Modified: search/trunk/src/test/java/org/hibernate/search/test/session/SessionTest.java
===================================================================
---
search/trunk/src/test/java/org/hibernate/search/test/session/SessionTest.java 2010-01-05
10:46:13 UTC (rev 18408)
+++
search/trunk/src/test/java/org/hibernate/search/test/session/SessionTest.java 2010-01-05
10:53:42 UTC (rev 18409)
@@ -28,6 +28,7 @@
import org.hibernate.Criteria;
import org.hibernate.Session;
+import org.hibernate.context.ThreadLocalSessionContext;
import org.hibernate.cfg.Configuration;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.search.FullTextSession;
@@ -78,6 +79,18 @@
s.close();
}
+ public void testThreadBoundSessionWrappingOutOfTransaction() throws Exception {
+ final Session session = getSessions().getCurrentSession();
+ try {
+ FullTextSession fts = Search.getFullTextSession( session );
+ //success
+ }
+ finally {
+ //clean up after the mess
+ ThreadLocalSessionContext.unbind( getSessions() );
+ }
+ }
+
protected Class[] getMappings() {
return new Class[] {
Email.class,
@@ -90,5 +103,7 @@
// for this test we explcitly set the auto commit mode since we are not explcitly
starting a transaction
// which could be a problem in some databases.
cfg.setProperty( "hibernate.connection.autocommit", "true" );
+ //needed for testThreadBoundSessionWrappingOutOfTransaction
+ cfg.setProperty( "hibernate.current_session_context_class",
"thread" );
}
}