|
From: <hib...@li...> - 2006-05-08 22:41:06
|
Author: max...@jb...
Date: 2006-05-08 18:41:00 -0400 (Mon, 08 May 2006)
New Revision: 9912
Modified:
trunk/Hibernate3/test/org/hibernate/test/array/ArrayTest.java
trunk/Hibernate3/test/org/hibernate/test/hql/CriteriaHQLAlignmentTest.java
trunk/Hibernate3/test/org/hibernate/test/idclass/IdClassTest.java
trunk/Hibernate3/test/org/hibernate/test/interceptor/InterceptorTest.java
trunk/Hibernate3/test/org/hibernate/test/unidir/BackrefTest.java
Log:
test to verify legacy classicquerytranslator count(*)
+ misc data test cleanup.
Modified: trunk/Hibernate3/test/org/hibernate/test/array/ArrayTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/array/ArrayTest.java 2006-05-08 21:43:02 UTC (rev 9911)
+++ trunk/Hibernate3/test/org/hibernate/test/array/ArrayTest.java 2006-05-08 22:41:00 UTC (rev 9912)
@@ -32,6 +32,9 @@
assertNotNull( a.getBs() );
assertEquals( a.getBs().length, 1 );
assertNotNull( a.getBs()[0] );
+
+ s.delete(a);
+ s.delete(a.getBs()[0]);
tx.commit();
s.close();
}
Modified: trunk/Hibernate3/test/org/hibernate/test/hql/CriteriaHQLAlignmentTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/hql/CriteriaHQLAlignmentTest.java 2006-05-08 21:43:02 UTC (rev 9911)
+++ trunk/Hibernate3/test/org/hibernate/test/hql/CriteriaHQLAlignmentTest.java 2006-05-08 22:41:00 UTC (rev 9912)
@@ -3,11 +3,14 @@
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.util.Collections;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.hibernate.Hibernate;
+import org.hibernate.MappingException;
+import org.hibernate.QueryException;
import org.hibernate.cfg.Configuration;
import org.hibernate.classic.Session;
import org.hibernate.criterion.Projections;
@@ -15,8 +18,11 @@
import org.hibernate.dialect.function.ClassicCountFunction;
import org.hibernate.dialect.function.ClassicSumFunction;
import org.hibernate.engine.SessionFactoryImplementor;
+import org.hibernate.hql.QueryTranslator;
+import org.hibernate.hql.QueryTranslatorFactory;
import org.hibernate.hql.ast.QueryTranslatorImpl;
import org.hibernate.hql.ast.tree.SelectClause;
+import org.hibernate.hql.classic.ClassicQueryTranslatorFactory;
/**
* Tests cases for ensuring alignment between HQL and Criteria behavior.
@@ -97,6 +103,16 @@
translator = createNewQueryTranslator( "select sum(h.bigDecimalValue) from Human h" );
assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
assertEquals( "incorrect return type", Hibernate.BIG_DECIMAL, translator.getReturnTypes()[0] );
+
+ // special case to test classicquery special case handling of count(*)
+ QueryTranslator oldQueryTranslator = null;
+ String hql = "select count(*) from Human h";
+ QueryTranslatorFactory classic = new ClassicQueryTranslatorFactory();
+ oldQueryTranslator = classic.createQueryTranslator( hql, hql, Collections.EMPTY_MAP, getSessionFactoryImplementor() );
+ oldQueryTranslator.compile( Collections.EMPTY_MAP, true);
+ assertEquals( "incorrect return type count", 1, oldQueryTranslator.getReturnTypes().length );
+ assertEquals( "incorrect return type", Hibernate.LONG, oldQueryTranslator.getReturnTypes()[0] );
+
}
// HHH-1724 Align Criteria with HQL aggregation return types.
@@ -157,7 +173,7 @@
s.close();
}
- public void testClassicTypes() {
+ public void testClassicHQLAggregationReturnTypes() {
Configuration classicCfg = new Configuration();
classicCfg.addSqlFunction( "count", new ClassicCountFunction());
classicCfg.addSqlFunction( "avg", new ClassicAvgFunction());
@@ -221,6 +237,16 @@
translator = createNewQueryTranslator( "select sum(h.bigDecimalValue) from Human h", factory );
assertEquals( "incorrect return type count", 1, translator.getReturnTypes().length );
assertEquals( "incorrect return type", Hibernate.BIG_DECIMAL, translator.getReturnTypes()[0] );
+
+ // special case to test classicquery special case handling of count(*)
+ QueryTranslator oldQueryTranslator = null;
+ String hql = "select count(*) from Human h";
+ QueryTranslatorFactory classic = new ClassicQueryTranslatorFactory();
+ oldQueryTranslator = classic.createQueryTranslator( hql, hql, Collections.EMPTY_MAP, factory );
+ oldQueryTranslator.compile( Collections.EMPTY_MAP, true);
+ assertEquals( "incorrect return type count", 1, oldQueryTranslator.getReturnTypes().length );
+ assertEquals( "incorrect return type", Hibernate.INTEGER, oldQueryTranslator.getReturnTypes()[0] );
+
}
public static Test suite() {
Modified: trunk/Hibernate3/test/org/hibernate/test/idclass/IdClassTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/idclass/IdClassTest.java 2006-05-08 21:43:02 UTC (rev 9911)
+++ trunk/Hibernate3/test/org/hibernate/test/idclass/IdClassTest.java 2006-05-08 22:41:00 UTC (rev 9912)
@@ -53,6 +53,9 @@
assertEquals( "Detroit", cust.getAddress() );
assertEquals( cust.getCustomerName(), custId.getCustomerName() );
assertEquals( cust.getOrgName(), custId.getOrgName() );
+
+ s.createQuery( "delete from Customer" ).executeUpdate();
+
t.commit();
s.close();
}
Modified: trunk/Hibernate3/test/org/hibernate/test/interceptor/InterceptorTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/interceptor/InterceptorTest.java 2006-05-08 21:43:02 UTC (rev 9911)
+++ trunk/Hibernate3/test/org/hibernate/test/interceptor/InterceptorTest.java 2006-05-08 22:41:00 UTC (rev 9912)
@@ -73,6 +73,7 @@
List logs = s.createCriteria(Log.class).list();
assertEquals( 2, logs.size() );
s.delete(u);
+ s.createQuery( "delete from Log" ).executeUpdate();
t.commit();
s.close();
}
Modified: trunk/Hibernate3/test/org/hibernate/test/unidir/BackrefTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/unidir/BackrefTest.java 2006-05-08 21:43:02 UTC (rev 9911)
+++ trunk/Hibernate3/test/org/hibernate/test/unidir/BackrefTest.java 2006-05-08 22:41:00 UTC (rev 9912)
@@ -64,6 +64,13 @@
s.merge(p3);
t.commit();
s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ s.createQuery( "delete from Child" ).executeUpdate();
+ s.createQuery( "delete from Parent" ).executeUpdate();
+ t.commit();
+ s.close();
}
protected String[] getMappings() {
|