Hibernate SVN: r14200 - in core/trunk: testsuite/src/test/java/org/hibernate/test/hql and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2007-11-16 15:25:59 -0500 (Fri, 16 Nov 2007)
New Revision: 14200
Modified:
core/trunk/core/src/main/java/org/hibernate/hql/ast/tree/DotNode.java
core/trunk/testsuite/src/test/java/org/hibernate/test/hql/BulkManipulationTest.java
Log:
HHH-2833 : insert-select query fails with NPE when select includes join
Modified: core/trunk/core/src/main/java/org/hibernate/hql/ast/tree/DotNode.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/hql/ast/tree/DotNode.java 2007-11-16 12:43:51 UTC (rev 14199)
+++ core/trunk/core/src/main/java/org/hibernate/hql/ast/tree/DotNode.java 2007-11-16 20:25:59 UTC (rev 14200)
@@ -336,7 +336,8 @@
joinIsNeeded = generateJoin && !isReferenceToPrimaryKey( parentAsDotNode.propertyName, entityType );
}
else if ( ! getWalker().isSelectStatement() ) {
- joinIsNeeded = false;
+ // in non-select queries, the only time we should need to join is if we are in a subquery from clause
+ joinIsNeeded = getWalker().getCurrentStatementType() == SqlTokenTypes.SELECT && getWalker().isInFrom();
}
else if ( REGRESSION_STYLE_JOIN_SUPPRESSION ) {
// this is the regression style determination which matches the logic of the classic translator
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/hql/BulkManipulationTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/hql/BulkManipulationTest.java 2007-11-16 12:43:51 UTC (rev 14199)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/hql/BulkManipulationTest.java 2007-11-16 20:25:59 UTC (rev 14200)
@@ -451,6 +451,18 @@
s.close();
}
+ public void testInsertWithSelectListUsingJoins() {
+ // this is just checking parsing and syntax...
+ Session s = openSession();
+ s.beginTransaction();
+ s.createQuery( "insert into Animal (description, bodyWeight) select h.description, h.bodyWeight from Human h where h.mother.mother is not null" ).executeUpdate();
+ s.createQuery( "insert into Animal (description, bodyWeight) select h.description, h.bodyWeight from Human h join h.mother m where m.mother is not null" ).executeUpdate();
+ s.createQuery( "delete from Animal" ).executeUpdate();
+ s.getTransaction().commit();
+ s.close();
+ }
+
+
// UPDATES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
public void testIncorrectSyntax() {
17 years
Hibernate SVN: r14199 - in search/trunk/src: java/org/hibernate/search/engine and 4 other directories.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-11-16 07:43:51 -0500 (Fri, 16 Nov 2007)
New Revision: 14199
Added:
search/trunk/src/test/org/hibernate/search/test/query/ProjectionToDelimStringResultTransformer.java
search/trunk/src/test/org/hibernate/search/test/query/ProjectionToMapResultTransformer.java
Modified:
search/trunk/src/java/org/hibernate/search/FullTextQuery.java
search/trunk/src/java/org/hibernate/search/engine/ProjectionLoader.java
search/trunk/src/java/org/hibernate/search/jpa/FullTextQuery.java
search/trunk/src/java/org/hibernate/search/jpa/impl/FullTextQueryImpl.java
search/trunk/src/java/org/hibernate/search/query/FullTextQueryImpl.java
search/trunk/src/test/org/hibernate/search/test/query/ProjectionQueryTest.java
Log:
HSEARCH-114 add resulttransformer
Modified: search/trunk/src/java/org/hibernate/search/FullTextQuery.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/FullTextQuery.java 2007-11-13 20:55:50 UTC (rev 14198)
+++ search/trunk/src/java/org/hibernate/search/FullTextQuery.java 2007-11-16 12:43:51 UTC (rev 14199)
@@ -5,6 +5,7 @@
import org.apache.lucene.search.Sort;
import org.hibernate.Criteria;
import org.hibernate.Query;
+import org.hibernate.transform.ResultTransformer;
/**
* The base interface for lucene powered searches.
@@ -91,4 +92,9 @@
*/
FullTextQuery setFetchSize(int i);
+ /**
+ * defines a result transformer used during projection, the Aliases provided are the projection aliases.
+ */
+ FullTextQuery setResultTransformer(ResultTransformer transformer);
+
}
Modified: search/trunk/src/java/org/hibernate/search/engine/ProjectionLoader.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/engine/ProjectionLoader.java 2007-11-13 20:55:50 UTC (rev 14198)
+++ search/trunk/src/java/org/hibernate/search/engine/ProjectionLoader.java 2007-11-16 12:43:51 UTC (rev 14199)
@@ -5,6 +5,7 @@
import java.util.List;
import org.hibernate.Session;
+import org.hibernate.transform.ResultTransformer;
/**
* @author Emmanuel Bernard
@@ -14,12 +15,20 @@
private Session session;
private ObjectLoader objectLoader;
private Boolean projectThis;
+ private ResultTransformer transformer;
+ private String[] aliases;
public void init(Session session, SearchFactoryImplementor searchFactoryImplementor) {
this.session = session;
this.searchFactoryImplementor = searchFactoryImplementor;
}
+ public void init(Session session, SearchFactoryImplementor searchFactoryImplementor, ResultTransformer transformer, String[] aliases) {
+ init( session, searchFactoryImplementor );
+ this.transformer = transformer;
+ this.aliases = aliases;
+ }
+
public Object load(EntityInfo entityInfo) {
initThisProjectionFlag( entityInfo );
if ( projectThis ) {
@@ -27,7 +36,12 @@
entityInfo.projection[index] = objectLoader.load( entityInfo );
}
}
- return entityInfo.projection;
+ if ( transformer != null ) {
+ return transformer.transformTuple( entityInfo.projection, aliases );
+ }
+ else {
+ return entityInfo.projection;
+ }
}
private void initThisProjectionFlag(EntityInfo entityInfo) {
@@ -56,7 +70,12 @@
}
}
for (EntityInfo entityInfo : entityInfos) {
- results.add( entityInfo.projection );
+ if ( transformer != null) {
+ results.add( transformer.transformTuple( entityInfo.projection, aliases ) );
+ }
+ else {
+ results.add( entityInfo.projection );
+ }
}
return results;
Modified: search/trunk/src/java/org/hibernate/search/jpa/FullTextQuery.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/jpa/FullTextQuery.java 2007-11-13 20:55:50 UTC (rev 14198)
+++ search/trunk/src/java/org/hibernate/search/jpa/FullTextQuery.java 2007-11-16 12:43:51 UTC (rev 14199)
@@ -6,6 +6,7 @@
import org.apache.lucene.search.Sort;
import org.apache.lucene.search.Filter;
import org.hibernate.Criteria;
+import org.hibernate.transform.ResultTransformer;
import org.hibernate.search.ProjectionConstants;
import org.hibernate.search.FullTextFilter;
@@ -81,4 +82,11 @@
* Disable a given filter by its name
*/
void disableFullTextFilter(String name);
+
+ /**
+ *
+ * defines a result transformer used during projection
+ *
+ */
+ FullTextQuery setResultTransformer(ResultTransformer transformer);
}
Modified: search/trunk/src/java/org/hibernate/search/jpa/impl/FullTextQueryImpl.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/jpa/impl/FullTextQueryImpl.java 2007-11-13 20:55:50 UTC (rev 14198)
+++ search/trunk/src/java/org/hibernate/search/jpa/impl/FullTextQueryImpl.java 2007-11-16 12:43:51 UTC (rev 14199)
@@ -1,40 +1,41 @@
// $Id$
package org.hibernate.search.jpa.impl;
+import java.io.Serializable;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashSet;
import java.util.List;
-import java.util.Date;
-import java.util.Calendar;
import java.util.Set;
-import java.util.HashSet;
-import java.io.Serializable;
-import javax.persistence.Query;
-import javax.persistence.TemporalType;
+import javax.persistence.EntityExistsException;
+import javax.persistence.EntityNotFoundException;
import javax.persistence.FlushModeType;
import javax.persistence.NoResultException;
import javax.persistence.NonUniqueResultException;
+import javax.persistence.OptimisticLockException;
import javax.persistence.PersistenceException;
-import javax.persistence.EntityExistsException;
-import javax.persistence.EntityNotFoundException;
-import javax.persistence.OptimisticLockException;
+import javax.persistence.Query;
+import javax.persistence.TemporalType;
-import org.hibernate.search.jpa.FullTextQuery;
-import org.hibernate.search.SearchException;
-import org.hibernate.search.FullTextFilter;
+import org.apache.lucene.search.Filter;
+import org.apache.lucene.search.Sort;
import org.hibernate.Criteria;
-import org.hibernate.TypeMismatchException;
+import org.hibernate.FlushMode;
import org.hibernate.HibernateException;
-import org.hibernate.StaleStateException;
import org.hibernate.ObjectNotFoundException;
-import org.hibernate.UnresolvableObjectException;
import org.hibernate.QueryException;
+import org.hibernate.Session;
+import org.hibernate.StaleObjectStateException;
+import org.hibernate.StaleStateException;
import org.hibernate.TransientObjectException;
-import org.hibernate.StaleObjectStateException;
-import org.hibernate.Session;
-import org.hibernate.FlushMode;
+import org.hibernate.TypeMismatchException;
+import org.hibernate.UnresolvableObjectException;
import org.hibernate.exception.ConstraintViolationException;
import org.hibernate.hql.QueryExecutionRequestException;
-import org.apache.lucene.search.Sort;
-import org.apache.lucene.search.Filter;
+import org.hibernate.search.FullTextFilter;
+import org.hibernate.search.SearchException;
+import org.hibernate.search.jpa.FullTextQuery;
+import org.hibernate.transform.ResultTransformer;
/**
* @author Emmanuel Bernard
@@ -80,6 +81,11 @@
query.disableFullTextFilter( name );
}
+ public FullTextQuery setResultTransformer(ResultTransformer transformer) {
+ query.setResultTransformer( transformer );
+ return this;
+ }
+
public List getResultList() {
try {
return query.list();
Modified: search/trunk/src/java/org/hibernate/search/query/FullTextQueryImpl.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/query/FullTextQueryImpl.java 2007-11-13 20:55:50 UTC (rev 14198)
+++ search/trunk/src/java/org/hibernate/search/query/FullTextQueryImpl.java 2007-11-16 12:43:51 UTC (rev 14199)
@@ -2,6 +2,7 @@
package org.hibernate.search.query;
import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -10,7 +11,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.lang.reflect.InvocationTargetException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -51,6 +51,7 @@
import org.hibernate.search.filter.FilterKey;
import org.hibernate.search.store.DirectoryProvider;
import org.hibernate.search.util.ContextHelper;
+import org.hibernate.transform.ResultTransformer;
/**
* Implementation of {@link org.hibernate.search.FullTextQuery}
@@ -71,6 +72,7 @@
private Filter filter;
private Criteria criteria;
private String[] indexProjection;
+ private ResultTransformer resultTransformer;
private SearchFactoryImplementor searchFactoryImplementor;
private Map<String, FullTextFilterImpl> filterDefinitions;
private int fetchSize = 1;
@@ -150,7 +152,7 @@
private Loader getLoader(Session session, SearchFactoryImplementor searchFactoryImplementor) {
if ( indexProjection != null ) {
ProjectionLoader loader = new ProjectionLoader();
- loader.init( session, searchFactoryImplementor );
+ loader.init( session, searchFactoryImplementor, resultTransformer, indexProjection );
return loader;
}
if ( criteria != null ) {
@@ -241,7 +243,14 @@
infos.add( extractor.extract( hits, index ) );
}
Loader loader = getLoader( sess, searchFactoryImplementor );
- return loader.load( infos.toArray( new EntityInfo[infos.size()] ) );
+ List list = loader.load( infos.toArray( new EntityInfo[infos.size()] ) );
+ if ( resultTransformer == null || loader instanceof ProjectionLoader) {
+ //stay consistent with transformTuple which can only be executed during a projection
+ return list;
+ }
+ else {
+ return resultTransformer.transformList( list );
+ }
}
catch (IOException e) {
throw new HibernateException( "Unable to query Lucene index", e );
@@ -530,6 +539,13 @@
return this;
}
+ @Override
+ public FullTextQuery setResultTransformer(ResultTransformer transformer) {
+ super.setResultTransformer( transformer );
+ this.resultTransformer = transformer;
+ return this;
+ }
+
public int executeUpdate() throws HibernateException {
throw new HibernateException( "Not supported operation" );
}
Modified: search/trunk/src/test/org/hibernate/search/test/query/ProjectionQueryTest.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/query/ProjectionQueryTest.java 2007-11-13 20:55:50 UTC (rev 14198)
+++ search/trunk/src/test/org/hibernate/search/test/query/ProjectionQueryTest.java 2007-11-16 12:43:51 UTC (rev 14199)
@@ -1,22 +1,23 @@
//$Id$
package org.hibernate.search.test.query;
+import java.io.Serializable;
+import java.util.Iterator;
import java.util.List;
-import java.util.Iterator;
-import java.io.Serializable;
+import java.util.Map;
import org.apache.lucene.analysis.StopAnalyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.document.Document;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.search.Query;
-import org.apache.lucene.document.Document;
-import org.hibernate.Transaction;
import org.hibernate.ScrollableResults;
import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.search.FullTextQuery;
import org.hibernate.search.FullTextSession;
import org.hibernate.search.Search;
import org.hibernate.search.SearchException;
-import org.hibernate.search.FullTextQuery;
import org.hibernate.search.test.SearchTestCase;
/**
@@ -48,16 +49,16 @@
projections.next();
Object[] projection = projections.get();
checkProjectionFirst( projection, s );
- assertTrue(projections.isFirst());
+ assertTrue( projections.isFirst() );
projections.last();
projection = projections.get();
checkProjectionLast( projection, s );
- assertTrue(projections.isLast());
+ assertTrue( projections.isLast() );
projections.next();
projection = projections.get();
- assertNull(projection);
+ assertNull( projection );
projections.previous();
projection = projections.get();
@@ -73,7 +74,7 @@
projections.scroll( -5 );
projection = projections.get();
- assertNull(projection);
+ assertNull( projection );
//cleanup
for (Object element : s.createQuery( "from " + Employee.class.getName() ).list()) s.delete( element );
@@ -81,11 +82,67 @@
s.close();
}
+ public void testResultTransformToDelimString() throws Exception {
+ FullTextSession s = Search.createFullTextSession( openSession() );
+ prepEmployeeIndex( s );
+
+ Transaction tx;
+ s.clear();
+ tx = s.beginTransaction();
+ QueryParser parser = new QueryParser( "dept", new StandardAnalyzer() );
+
+ Query query = parser.parse( "dept:ITech" );
+ org.hibernate.search.FullTextQuery hibQuery = s.createFullTextQuery( query, Employee.class );
+ hibQuery.setProjection( "id", "lastname", "dept", FullTextQuery.THIS, FullTextQuery.SCORE, FullTextQuery.BOOST, FullTextQuery.ID );
+ hibQuery.setResultTransformer( new ProjectionToDelimStringResultTransformer() );
+
+ List<String> result = (List<String>) hibQuery.list();
+ assertTrue( "incorrect transformation", result.get( 0 ).startsWith( "1000, Griffin, ITech" ) );
+ assertTrue( "incorrect transformation", result.get( 1 ).startsWith( "1002, Jimenez, ITech" ) );
+
+ //cleanup
+ for ( Object element : s.createQuery( "from " + Employee.class.getName() ).list() ) {
+ s.delete( element );
+ }
+ tx.commit();
+ s.close();
+ }
+
+ public void testResultTransformMap() throws Exception {
+ FullTextSession s = Search.createFullTextSession( openSession() );
+ prepEmployeeIndex( s );
+
+ Transaction tx;
+ s.clear();
+ tx = s.beginTransaction();
+ QueryParser parser = new QueryParser( "dept", new StandardAnalyzer() );
+
+ Query query = parser.parse( "dept:ITech" );
+ org.hibernate.search.FullTextQuery hibQuery = s.createFullTextQuery( query, Employee.class );
+ hibQuery.setProjection( "id", "lastname", "dept", FullTextQuery.THIS, FullTextQuery.SCORE, FullTextQuery.BOOST, FullTextQuery.DOCUMENT, FullTextQuery.ID );
+
+ hibQuery.setResultTransformer( new ProjectionToMapResultTransformer() );
+
+ List transforms = hibQuery.list();
+ Map map = (Map) transforms.get( 1 );
+ assertEquals( "incorrect transformation", "ITech", map.get( "dept" ) );
+ assertEquals( "incorrect transformation", 1002, map.get( "id" ) );
+ assertTrue( "incorrect transformation", map.get( FullTextQuery.DOCUMENT ) instanceof Document );
+ assertEquals( "incorrect transformation", "1002", ( (Document) map.get( FullTextQuery.DOCUMENT ) ).get( "id" ) );
+
+ //cleanup
+ for (Object element : s.createQuery( "from " + Employee.class.getName() ).list()) {
+ s.delete( element );
+ }
+ tx.commit();
+ s.close();
+ }
+
private void checkProjectionFirst(Object[] projection, Session s) {
assertEquals( "id incorrect", 1000, projection[0] );
assertEquals( "lastname incorrect", "Griffin", projection[1] );
assertEquals( "dept incorrect", "ITech", projection[2] );
- assertEquals( "THIS incorrect", projection[3], s.get(Employee.class, (Serializable) projection[0]) );
+ assertEquals( "THIS incorrect", projection[3], s.get( Employee.class, (Serializable) projection[0] ) );
assertEquals( "SCORE incorrect", 1.0F, projection[4] );
assertEquals( "BOOST incorrect", 1.0F, projection[5] );
assertTrue( "DOCUMENT incorrect", projection[6] instanceof Document );
@@ -97,7 +154,7 @@
assertEquals( "id incorrect", 1004, projection[0] );
assertEquals( "lastname incorrect", "Whetbrook", projection[1] );
assertEquals( "dept incorrect", "ITech", projection[2] );
- assertEquals( "THIS incorrect", projection[3], s.get(Employee.class, (Serializable) projection[0]) );
+ assertEquals( "THIS incorrect", projection[3], s.get( Employee.class, (Serializable) projection[0] ) );
assertEquals( "SCORE incorrect", 1.0F, projection[4] );
assertEquals( "BOOST incorrect", 1.0F, projection[5] );
assertTrue( "DOCUMENT incorrect", projection[6] instanceof Document );
@@ -109,7 +166,7 @@
assertEquals( "id incorrect", 1003, projection[0] );
assertEquals( "lastname incorrect", "Stejskal", projection[1] );
assertEquals( "dept incorrect", "ITech", projection[2] );
- assertEquals( "THIS incorrect", projection[3], s.get(Employee.class, (Serializable) projection[0]) );
+ assertEquals( "THIS incorrect", projection[3], s.get( Employee.class, (Serializable) projection[0] ) );
assertEquals( "SCORE incorrect", 1.0F, projection[4] );
assertEquals( "BOOST incorrect", 1.0F, projection[5] );
assertTrue( "DOCUMENT incorrect", projection[6] instanceof Document );
@@ -137,7 +194,7 @@
assertNotNull( projection );
counter++;
assertEquals( "dept incorrect", "ITech", projection[2] );
- assertEquals( "THIS incorrect", projection[3], s.get(Employee.class, (Serializable) projection[0]) );
+ assertEquals( "THIS incorrect", projection[3], s.get( Employee.class, (Serializable) projection[0] ) );
assertEquals( "SCORE incorrect", 1.0F, projection[4] );
assertEquals( "BOOST incorrect", 1.0F, projection[5] );
assertTrue( "DOCUMENT incorrect", projection[6] instanceof Document );
@@ -173,7 +230,7 @@
assertEquals( "last name incorrect", "Jackson", projection[1] );
assertEquals( "dept incorrect", "Accounting", projection[2] );
assertEquals( "THIS incorrect", "Jackson", ( (Employee) projection[3] ).getLastname() );
- assertEquals( "THIS incorrect", projection[3], s.get(Employee.class, (Serializable) projection[0]) );
+ assertEquals( "THIS incorrect", projection[3], s.get( Employee.class, (Serializable) projection[0] ) );
assertEquals( "SCORE incorrect", 1.0F, projection[4] );
assertEquals( "BOOST incorrect", 1.0F, projection[5] );
assertTrue( "DOCUMENT incorrect", projection[6] instanceof Document );
@@ -191,7 +248,7 @@
assertTrue( "DOCUMENT incorrect", projection[0] instanceof Document );
assertEquals( "DOCUMENT size incorrect", 4, ( (Document) projection[0] ).getFields().size() );
- assertEquals( "THIS incorrect", projection[1], s.get(Employee.class, (Serializable) projection[4]) );
+ assertEquals( "THIS incorrect", projection[1], s.get( Employee.class, (Serializable) projection[4] ) );
assertEquals( "SCORE incorrect", 1.0F, projection[2] );
assertNull( "BOOST not removed", projection[3] );
assertEquals( "ID incorrect", 1001, projection[4] );
Added: search/trunk/src/test/org/hibernate/search/test/query/ProjectionToDelimStringResultTransformer.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/query/ProjectionToDelimStringResultTransformer.java (rev 0)
+++ search/trunk/src/test/org/hibernate/search/test/query/ProjectionToDelimStringResultTransformer.java 2007-11-16 12:43:51 UTC (rev 14199)
@@ -0,0 +1,23 @@
+package org.hibernate.search.test.query;
+
+import java.util.List;
+
+import org.hibernate.transform.ResultTransformer;
+
+/**
+ * @author John Griffin
+ */
+public class ProjectionToDelimStringResultTransformer implements ResultTransformer {
+
+ public Object transformTuple(Object[] tuple, String[] aliases) {
+ String s = tuple[0].toString();
+ for (int i = 1; i < tuple.length; i++) {
+ s = s + ", " + tuple[i].toString();
+ }
+ return s;
+ }
+
+ public List transformList(List collection) {
+ return collection;
+ }
+}
Added: search/trunk/src/test/org/hibernate/search/test/query/ProjectionToMapResultTransformer.java
===================================================================
--- search/trunk/src/test/org/hibernate/search/test/query/ProjectionToMapResultTransformer.java (rev 0)
+++ search/trunk/src/test/org/hibernate/search/test/query/ProjectionToMapResultTransformer.java 2007-11-16 12:43:51 UTC (rev 14199)
@@ -0,0 +1,28 @@
+package org.hibernate.search.test.query;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.hibernate.transform.ResultTransformer;
+
+/**
+ * @author John Griffin
+ */
+public class ProjectionToMapResultTransformer implements ResultTransformer {
+
+ public Object transformTuple(Object[] tuple, String[] aliases) {
+ Map result = new HashMap( tuple.length );
+ for (int i = 0; i < tuple.length; i++) {
+ String key = aliases[i];
+ if ( key != null ) {
+ result.put( key, tuple[i] );
+ }
+ }
+ return result;
+ }
+
+ public List transformList(List collection) {
+ return collection;
+ }
+}
17 years
Hibernate SVN: r14198 - in core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test: cache/jbc2/collection and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: bstansberry(a)jboss.com
Date: 2007-11-13 15:55:50 -0500 (Tue, 13 Nov 2007)
New Revision: 14198
Modified:
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractJBossCacheTestCase.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/AbstractCollectionRegionAccessStrategyTestCase.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/AbstractEntityRegionAccessStrategyTestCase.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/CacheTestCaseBase.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/util/CacheTestSupport.java
Log:
Run tests w/ java.net.preferIPv4Stack=true; cluster formation is very slow otherwise on some systems
Modified: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractJBossCacheTestCase.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractJBossCacheTestCase.java 2007-11-13 17:12:02 UTC (rev 14197)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractJBossCacheTestCase.java 2007-11-13 20:55:50 UTC (rev 14198)
@@ -27,7 +27,6 @@
private CacheTestSupport testSupport = new CacheTestSupport();
protected final Logger log = LoggerFactory.getLogger(getClass());
-
public AbstractJBossCacheTestCase(String name) {
super(name);
Modified: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/AbstractCollectionRegionAccessStrategyTestCase.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/AbstractCollectionRegionAccessStrategyTestCase.java 2007-11-13 17:12:02 UTC (rev 14197)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/AbstractCollectionRegionAccessStrategyTestCase.java 2007-11-13 20:55:50 UTC (rev 14198)
@@ -503,7 +503,10 @@
private static class AccessStrategyTestSetup extends TestSetup {
+ private static final String PREFER_IPV4STACK = "java.net.preferIPv4Stack";
+
private String configName;
+ private String preferIPv4Stack;
public AccessStrategyTestSetup(Test test, String configName) {
super(test);
@@ -512,7 +515,12 @@
@Override
protected void setUp() throws Exception {
- super.setUp();
+ super.setUp();
+
+ // Try to ensure we use IPv4; otherwise cluster formation is very slow
+ preferIPv4Stack = System.getProperty(PREFER_IPV4STACK);
+ System.setProperty(PREFER_IPV4STACK, "true");
+
localCfg = createConfiguration(configName);
localRegionFactory = CacheTestUtil.startRegionFactory(localCfg);
localCache = localRegionFactory.getCacheInstanceManager().getCollectionCacheInstance();
@@ -523,8 +531,16 @@
}
@Override
- protected void tearDown() throws Exception {
- super.tearDown();
+ protected void tearDown() throws Exception {
+ try {
+ super.tearDown();
+ }
+ finally {
+ if (preferIPv4Stack == null)
+ System.clearProperty(PREFER_IPV4STACK);
+ else
+ System.setProperty(PREFER_IPV4STACK, preferIPv4Stack);
+ }
if (localRegionFactory != null)
localRegionFactory.stop();
Modified: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/AbstractEntityRegionAccessStrategyTestCase.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/AbstractEntityRegionAccessStrategyTestCase.java 2007-11-13 17:12:02 UTC (rev 14197)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/AbstractEntityRegionAccessStrategyTestCase.java 2007-11-13 20:55:50 UTC (rev 14198)
@@ -696,7 +696,10 @@
private static class AccessStrategyTestSetup extends TestSetup {
+ private static final String PREFER_IPV4STACK = "java.net.preferIPv4Stack";
+
private String configName;
+ private String preferIPv4Stack;
public AccessStrategyTestSetup(Test test, String configName) {
super(test);
@@ -705,7 +708,20 @@
@Override
protected void setUp() throws Exception {
- super.setUp();
+ try {
+ super.tearDown();
+ }
+ finally {
+ if (preferIPv4Stack == null)
+ System.clearProperty(PREFER_IPV4STACK);
+ else
+ System.setProperty(PREFER_IPV4STACK, preferIPv4Stack);
+ }
+
+ // Try to ensure we use IPv4; otherwise cluster formation is very slow
+ preferIPv4Stack = System.getProperty(PREFER_IPV4STACK);
+ System.setProperty(PREFER_IPV4STACK, "true");
+
localCfg = createConfiguration(configName);
localRegionFactory = CacheTestUtil.startRegionFactory(localCfg);
localCache = localRegionFactory.getCacheInstanceManager().getEntityCacheInstance();
Modified: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/CacheTestCaseBase.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/CacheTestCaseBase.java 2007-11-13 17:12:02 UTC (rev 14197)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/CacheTestCaseBase.java 2007-11-13 20:55:50 UTC (rev 14198)
@@ -3,6 +3,8 @@
import org.hibernate.cache.RegionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment;
+import org.hibernate.cfg.Mappings;
+import org.hibernate.dialect.Dialect;
import org.hibernate.junit.functional.FunctionalTestCase;
import org.hibernate.test.tm.DummyConnectionProvider;
import org.hibernate.test.tm.DummyTransactionManagerLookup;
@@ -14,6 +16,10 @@
*/
public abstract class CacheTestCaseBase extends FunctionalTestCase {
+ private static final String PREFER_IPV4STACK = "java.net.preferIPv4Stack";
+
+ private String preferIPv4Stack;
+
// note that a lot of the functionality here is intended to be used
// in creating specific tests for each CacheProvider that would extend
// from a base test case (this) for common requirement testing...
@@ -44,7 +50,7 @@
public String getCacheConcurrencyStrategy() {
return "transactional";
- }
+ }
/**
* The cache provider to be tested.
@@ -78,4 +84,30 @@
* @return The config resource location.
*/
protected abstract String getConfigResourceLocation();
+
+ @Override
+ public void afterConfigurationBuilt(Mappings mappings, Dialect dialect) {
+
+ super.afterConfigurationBuilt(mappings, dialect);
+
+ // Try to ensure we use IPv4; otherwise cluster formation is very slow
+ preferIPv4Stack = System.getProperty(PREFER_IPV4STACK);
+ System.setProperty(PREFER_IPV4STACK, "true");
+ }
+
+ @Override
+ protected void cleanupTest() throws Exception {
+ try {
+ super.cleanupTest();
+ }
+ finally {
+ if (preferIPv4Stack == null)
+ System.clearProperty(PREFER_IPV4STACK);
+ else
+ System.setProperty(PREFER_IPV4STACK, preferIPv4Stack);
+ }
+
+ }
+
+
}
Modified: core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/util/CacheTestSupport.java
===================================================================
--- core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/util/CacheTestSupport.java 2007-11-13 17:12:02 UTC (rev 14197)
+++ core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/util/CacheTestSupport.java 2007-11-13 20:55:50 UTC (rev 14198)
@@ -31,9 +31,12 @@
*/
public class CacheTestSupport {
+ private static final String PREFER_IPV4STACK = "java.net.preferIPv4Stack";
+
private Set<Cache> caches = new HashSet();
private Set<RegionFactory> factories = new HashSet();
private Exception exception;
+ private String preferIPv4Stack;
public void registerCache(Cache cache) {
caches.add(cache);
@@ -51,12 +54,23 @@
factories.remove(factory);
}
- public void setUp() throws Exception {
+ public void setUp() throws Exception {
+
+ // Try to ensure we use IPv4; otherwise cluster formation is very slow
+ preferIPv4Stack = System.getProperty(PREFER_IPV4STACK);
+ System.setProperty(PREFER_IPV4STACK, "true");
+
cleanUp();
throwStoredException();
}
public void tearDown() throws Exception {
+
+ if (preferIPv4Stack == null)
+ System.clearProperty(PREFER_IPV4STACK);
+ else
+ System.setProperty(PREFER_IPV4STACK, preferIPv4Stack);
+
cleanUp();
throwStoredException();
}
17 years
Hibernate SVN: r14197 - search/trunk/src/java/org/hibernate/search/engine.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2007-11-13 12:12:02 -0500 (Tue, 13 Nov 2007)
New Revision: 14197
Modified:
search/trunk/src/java/org/hibernate/search/engine/DocumentBuilder.java
Log:
HSEARCH-137 Wrong exception message when FieldBridge and document id are used
Modified: search/trunk/src/java/org/hibernate/search/engine/DocumentBuilder.java
===================================================================
--- search/trunk/src/java/org/hibernate/search/engine/DocumentBuilder.java 2007-11-08 18:21:03 UTC (rev 14196)
+++ search/trunk/src/java/org/hibernate/search/engine/DocumentBuilder.java 2007-11-13 17:12:02 UTC (rev 14197)
@@ -190,7 +190,7 @@
}
else {
throw new SearchException(
- "Bridge for document id does not implement IdFieldBridge: " + member.getName() );
+ "Bridge for document id does not implement TwoWayFieldBridge: " + member.getName() );
}
idBoost = getBoost( member );
setAccessible( member );
17 years
Hibernate SVN: r14196 - tags/TOOLS_3_2_0_CR1.
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2007-11-08 13:21:03 -0500 (Thu, 08 Nov 2007)
New Revision: 14196
Added:
tags/TOOLS_3_2_0_CR1/HibernateExt/
Log:
tag tools CR1
Copied: tags/TOOLS_3_2_0_CR1/HibernateExt (from rev 14195, branches/Branch_3_2/HibernateExt)
17 years
Hibernate SVN: r14195 - tags.
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2007-11-08 13:20:16 -0500 (Thu, 08 Nov 2007)
New Revision: 14195
Added:
tags/TOOLS_3_2_0_CR1/
Log:
tag for tools cr1
17 years
Hibernate SVN: r14194 - branches/Branch_3_2/HibernateExt.
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2007-11-08 13:15:56 -0500 (Thu, 08 Nov 2007)
New Revision: 14194
Modified:
branches/Branch_3_2/HibernateExt/build.sh
Log:
outdated .sh
Modified: branches/Branch_3_2/HibernateExt/build.sh
===================================================================
--- branches/Branch_3_2/HibernateExt/build.sh 2007-11-08 18:10:40 UTC (rev 14193)
+++ branches/Branch_3_2/HibernateExt/build.sh 2007-11-08 18:15:56 UTC (rev 14194)
@@ -1,4 +1,4 @@
#!/bin/sh
CURDIR=`dirname $0`
-HIBERNATECORE=$CURDIR/../hibernate-3.1
+HIBERNATECORE=$CURDIR/../hibernate-3.2
java -cp "$HIBERNATECORE/lib/ant-launcher-1.6.5.jar" org.apache.tools.ant.launch.Launcher -lib $HIBERNATECORE/lib $*
17 years
Hibernate SVN: r14191 - in branches/Branch_3_2/HibernateExt/tools: src/java/org/hibernate/tool and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2007-11-08 12:16:57 -0500 (Thu, 08 Nov 2007)
New Revision: 14191
Modified:
branches/Branch_3_2/HibernateExt/tools/build.xml
branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/Version.java
Log:
bump version
Modified: branches/Branch_3_2/HibernateExt/tools/build.xml
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/build.xml 2007-11-08 17:13:00 UTC (rev 14190)
+++ branches/Branch_3_2/HibernateExt/tools/build.xml 2007-11-08 17:16:57 UTC (rev 14191)
@@ -7,7 +7,7 @@
<!-- Name of project and version, used to create filenames -->
<property name="Name" value="Hibernate Tools"/>
<property name="name" value="hibernate-tools"/>
- <property name="version" value="3.2.0b11"/>
+ <property name="version" value="3.2.0.CR1"/>
<property name="javadoc.packagenames" value="org.hibernate.tool"/>
Modified: branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/Version.java
===================================================================
--- branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/Version.java 2007-11-08 17:13:00 UTC (rev 14190)
+++ branches/Branch_3_2/HibernateExt/tools/src/java/org/hibernate/tool/Version.java 2007-11-08 17:16:57 UTC (rev 14191)
@@ -5,7 +5,7 @@
final public class Version {
- public static final String VERSION = "3.2.0.b11";
+ public static final String VERSION = "3.2.0.CR1";
private static final Version instance = new Version();
17 years