Hibernate SVN: r10406 - trunk/Hibernate3/test/org/hibernate/test/compositeelement
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-09-01 14:41:02 -0400 (Fri, 01 Sep 2006)
New Revision: 10406
Modified:
trunk/Hibernate3/test/org/hibernate/test/compositeelement/CompositeElementTest.java
Log:
fix on sybase and sqlserver by using len() instead of length() for formula mapping
Modified: trunk/Hibernate3/test/org/hibernate/test/compositeelement/CompositeElementTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/compositeelement/CompositeElementTest.java 2006-09-01 18:40:39 UTC (rev 10405)
+++ trunk/Hibernate3/test/org/hibernate/test/compositeelement/CompositeElementTest.java 2006-09-01 18:41:02 UTC (rev 10406)
@@ -6,17 +6,84 @@
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.HibernateException;
+import org.hibernate.util.XMLHelper;
+import org.hibernate.util.StringHelper;
+import org.hibernate.util.CollectionHelper;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.HbmBinder;
+import org.hibernate.dialect.SybaseDialect;
+import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.test.TestCase;
+import org.xml.sax.InputSource;
+import org.dom4j.Element;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+
/**
* @author Gavin King
*/
public class CompositeElementTest extends TestCase {
-
+
public CompositeElementTest(String str) {
super(str);
}
-
+
+ private boolean hasLengthFunction() {
+ // neither support length() as a function, but each has len() which
+ // is the same semantic
+ return ! ( getDialect() instanceof SybaseDialect || getDialect() instanceof SQLServerDialect );
+ }
+
+ protected String[] getMappings() {
+ return hasLengthFunction() ? new String[] { "compositeelement/Parent.hbm.xml" } : new String[0];
+ }
+
+ protected void configure(Configuration cfg) {
+ super.configure( cfg );
+ if ( !hasLengthFunction() ) {
+ try {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ InputStream xmlInputStream = cl.getResourceAsStream( getBaseForMappings() + "compositeelement/Parent.hbm.xml" );
+ XMLHelper xmlHelper = new XMLHelper();
+ ArrayList errors = new ArrayList();
+ org.dom4j.Document doc = xmlHelper.createSAXReader( "XML InputStream", errors, cfg.getEntityResolver() )
+ .read( new InputSource( xmlInputStream ) );
+
+ Element hmNode = doc.getRootElement();
+ Iterator classNodes = hmNode.elementIterator( "class" );
+ while ( classNodes.hasNext() ) {
+ Element classNode = ( Element ) classNodes.next();
+ if ( "Parent".equals( classNode.attributeValue( "name" ) ) ) {
+ Iterator sets = classNode.elementIterator( "set" );
+ while ( sets.hasNext() ) {
+ Element set = ( Element ) sets.next();
+ if ( "children".equals( set.attributeValue( "name" ) ) ) {
+ Element component = set.element( "composite-element" );
+ Iterator componentProperties = component.elementIterator( "property" );
+ while ( componentProperties.hasNext() ) {
+ Element property = ( Element ) componentProperties.next();
+ if ( "bioLength".equals( property.attributeValue( "name" ) ) ) {
+ String formula = property.attributeValue( "formula" );
+ property.attribute( "formula" ).setValue( StringHelper.replace( formula, "length", "len" ) );
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // Whew! ;)
+ HbmBinder.bindRoot( doc, cfg.createMappings(), CollectionHelper.EMPTY_MAP );
+ }
+ catch( Throwable t ) {
+ throw new HibernateException( "Grrr" );
+ }
+ }
+ }
+
public void testHandSQL() {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -26,16 +93,16 @@
c.setParent(p);
s.save(p);
s.flush();
-
+
p.getChildren().remove(c);
c.setParent(null);
s.flush();
-
+
p.getChildren().add(c);
c.setParent(p);
t.commit();
s.close();
-
+
s = openSession();
t = s.beginTransaction();
s.createQuery("select distinct p from Parent p join p.children c where c.name like 'Child%'").uniqueResult();
@@ -47,7 +114,7 @@
p = (Parent) s.createQuery("from Parent p left join fetch p.children").uniqueResult();
t.commit();
s.close();
-
+
s = openSession();
t = s.beginTransaction();
s.delete(p);
@@ -55,11 +122,6 @@
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "compositeelement/Parent.hbm.xml" };
- }
-
public static Test suite() {
return new TestSuite(CompositeElementTest.class);
}
18 years, 4 months
Hibernate SVN: r10405 - branches/Branch_3_2/Hibernate3/test/org/hibernate/test/compositeelement
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-09-01 14:40:39 -0400 (Fri, 01 Sep 2006)
New Revision: 10405
Modified:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/compositeelement/CompositeElementTest.java
Log:
fix on sybase and sqlserver by using len() instead of length() for formula mapping
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/compositeelement/CompositeElementTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/compositeelement/CompositeElementTest.java 2006-09-01 18:39:40 UTC (rev 10404)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/compositeelement/CompositeElementTest.java 2006-09-01 18:40:39 UTC (rev 10405)
@@ -6,17 +6,84 @@
import org.hibernate.Session;
import org.hibernate.Transaction;
+import org.hibernate.HibernateException;
+import org.hibernate.util.XMLHelper;
+import org.hibernate.util.StringHelper;
+import org.hibernate.util.CollectionHelper;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.HbmBinder;
+import org.hibernate.dialect.SybaseDialect;
+import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.test.TestCase;
+import org.xml.sax.InputSource;
+import org.dom4j.Element;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+
/**
* @author Gavin King
*/
public class CompositeElementTest extends TestCase {
-
+
public CompositeElementTest(String str) {
super(str);
}
-
+
+ private boolean hasLengthFunction() {
+ // neither support length() as a function, but each has len() which
+ // is the same semantic
+ return ! ( getDialect() instanceof SybaseDialect || getDialect() instanceof SQLServerDialect );
+ }
+
+ protected String[] getMappings() {
+ return hasLengthFunction() ? new String[] { "compositeelement/Parent.hbm.xml" } : new String[0];
+ }
+
+ protected void configure(Configuration cfg) {
+ super.configure( cfg );
+ if ( !hasLengthFunction() ) {
+ try {
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ InputStream xmlInputStream = cl.getResourceAsStream( getBaseForMappings() + "compositeelement/Parent.hbm.xml" );
+ XMLHelper xmlHelper = new XMLHelper();
+ ArrayList errors = new ArrayList();
+ org.dom4j.Document doc = xmlHelper.createSAXReader( "XML InputStream", errors, cfg.getEntityResolver() )
+ .read( new InputSource( xmlInputStream ) );
+
+ Element hmNode = doc.getRootElement();
+ Iterator classNodes = hmNode.elementIterator( "class" );
+ while ( classNodes.hasNext() ) {
+ Element classNode = ( Element ) classNodes.next();
+ if ( "Parent".equals( classNode.attributeValue( "name" ) ) ) {
+ Iterator sets = classNode.elementIterator( "set" );
+ while ( sets.hasNext() ) {
+ Element set = ( Element ) sets.next();
+ if ( "children".equals( set.attributeValue( "name" ) ) ) {
+ Element component = set.element( "composite-element" );
+ Iterator componentProperties = component.elementIterator( "property" );
+ while ( componentProperties.hasNext() ) {
+ Element property = ( Element ) componentProperties.next();
+ if ( "bioLength".equals( property.attributeValue( "name" ) ) ) {
+ String formula = property.attributeValue( "formula" );
+ property.attribute( "formula" ).setValue( StringHelper.replace( formula, "length", "len" ) );
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // Whew! ;)
+ HbmBinder.bindRoot( doc, cfg.createMappings(), CollectionHelper.EMPTY_MAP );
+ }
+ catch( Throwable t ) {
+ throw new HibernateException( "Grrr" );
+ }
+ }
+ }
+
public void testHandSQL() {
Session s = openSession();
Transaction t = s.beginTransaction();
@@ -26,16 +93,16 @@
c.setParent(p);
s.save(p);
s.flush();
-
+
p.getChildren().remove(c);
c.setParent(null);
s.flush();
-
+
p.getChildren().add(c);
c.setParent(p);
t.commit();
s.close();
-
+
s = openSession();
t = s.beginTransaction();
s.createQuery("select distinct p from Parent p join p.children c where c.name like 'Child%'").uniqueResult();
@@ -47,7 +114,7 @@
p = (Parent) s.createQuery("from Parent p left join fetch p.children").uniqueResult();
t.commit();
s.close();
-
+
s = openSession();
t = s.beginTransaction();
s.delete(p);
@@ -55,11 +122,8 @@
s.close();
}
-
- protected String[] getMappings() {
- return new String[] { "compositeelement/Parent.hbm.xml" };
- }
+
public static Test suite() {
return new TestSuite(CompositeElementTest.class);
}
18 years, 4 months
Hibernate SVN: r10404 - branches/Branch_3_2/Hibernate3/test/org/hibernate/test/interfaceproxy
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-09-01 14:39:40 -0400 (Fri, 01 Sep 2006)
New Revision: 10404
Modified:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/interfaceproxy/InterfaceProxyTest.java
Log:
data cleanup
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/interfaceproxy/InterfaceProxyTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/interfaceproxy/InterfaceProxyTest.java 2006-09-01 18:39:25 UTC (rev 10403)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/interfaceproxy/InterfaceProxyTest.java 2006-09-01 18:39:40 UTC (rev 10404)
@@ -77,8 +77,8 @@
catch (ClassCastException cce) {
//correct
}
-
-
+
+ s.createQuery( "delete ItemImpl" ).executeUpdate();
t.commit();
s.close();
}
18 years, 4 months
Hibernate SVN: r10403 - trunk/Hibernate3/test/org/hibernate/test/interfaceproxy
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-09-01 14:39:25 -0400 (Fri, 01 Sep 2006)
New Revision: 10403
Modified:
trunk/Hibernate3/test/org/hibernate/test/interfaceproxy/InterfaceProxyTest.java
Log:
data cleanup
Modified: trunk/Hibernate3/test/org/hibernate/test/interfaceproxy/InterfaceProxyTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/interfaceproxy/InterfaceProxyTest.java 2006-09-01 18:35:52 UTC (rev 10402)
+++ trunk/Hibernate3/test/org/hibernate/test/interfaceproxy/InterfaceProxyTest.java 2006-09-01 18:39:25 UTC (rev 10403)
@@ -77,8 +77,8 @@
catch (ClassCastException cce) {
//correct
}
-
-
+
+ s.createQuery( "delete ItemImpl" ).executeUpdate();
t.commit();
s.close();
}
18 years, 4 months
Hibernate SVN: r10402 - trunk/Hibernate3/test/org/hibernate/test/mixed
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-09-01 14:35:52 -0400 (Fri, 01 Sep 2006)
New Revision: 10402
Modified:
trunk/Hibernate3/test/org/hibernate/test/mixed/MixedTest.java
Log:
data cleanup
Modified: trunk/Hibernate3/test/org/hibernate/test/mixed/MixedTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/mixed/MixedTest.java 2006-09-01 18:35:19 UTC (rev 10401)
+++ trunk/Hibernate3/test/org/hibernate/test/mixed/MixedTest.java 2006-09-01 18:35:52 UTC (rev 10402)
@@ -83,6 +83,7 @@
assertNotNull( d2.getCreated() );
assertNotNull( d2.getModified() );
+ s.delete( d.getParent() );
s.delete( d );
s.delete( d2 );
18 years, 4 months
Hibernate SVN: r10401 - trunk/Hibernate3/test/org/hibernate/test/sql
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-09-01 14:35:19 -0400 (Fri, 01 Sep 2006)
New Revision: 10401
Modified:
trunk/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java
Log:
cleanup : wow
Modified: trunk/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java 2006-09-01 18:32:37 UTC (rev 10400)
+++ trunk/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java 2006-09-01 18:35:19 UTC (rev 10401)
@@ -399,14 +399,14 @@
public void testAutoDetectAliasing() {
Session s = openSession();
Transaction t = s.beginTransaction();
- Organization ifa = new Organization("IFA");
- Organization jboss = new Organization("JBoss");
- Person gavin = new Person("Gavin");
- Employment emp = new Employment(gavin, jboss, "AU");
- Serializable orgId = s.save(jboss);
- Serializable orgId2 = s.save(ifa);
- s.save(gavin);
- s.save(emp);
+ Organization ifa = new Organization( "IFA" );
+ Organization jboss = new Organization( "JBoss" );
+ Person gavin = new Person( "Gavin" );
+ Employment emp = new Employment( gavin, jboss, "AU" );
+ Serializable orgId = s.save( jboss );
+ Serializable orgId2 = s.save( ifa );
+ s.save( gavin );
+ s.save( emp );
t.commit();
s.close();
@@ -415,50 +415,53 @@
List list = s.createSQLQuery( getEmploymentSQL() )
.addEntity( Employment.class.getName() )
.list();
- assertEquals( 1,list.size() );
+ assertEquals( 1, list.size() );
- Employment emp2 = (Employment) list.get(0);
- assertEquals(emp2.getEmploymentId(), emp.getEmploymentId() );
- assertEquals(emp2.getStartDate().getDate(), emp.getStartDate().getDate() );
- assertEquals(emp2.getEndDate(), emp.getEndDate() );
+ Employment emp2 = ( Employment ) list.get( 0 );
+ assertEquals( emp2.getEmploymentId(), emp.getEmploymentId() );
+ assertEquals( emp2.getStartDate().getDate(), emp.getStartDate().getDate() );
+ assertEquals( emp2.getEndDate(), emp.getEndDate() );
s.clear();
list = s.createSQLQuery( getEmploymentSQL() )
- .addEntity( Employment.class.getName() )
- .setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP)
- .list();
- assertEquals( 1,list.size() );
- Map m = (Map) list.get(0);
- assertTrue(m.containsKey("Employment"));
- assertEquals(1,m.size());
+ .addEntity( Employment.class.getName() )
+ .setResultTransformer( Transformers.ALIAS_TO_ENTITY_MAP )
+ .list();
+ assertEquals( 1, list.size() );
+ Map m = ( Map ) list.get( 0 );
+ assertTrue( m.containsKey( "Employment" ) );
+ assertEquals( 1, m.size() );
- list = s.createSQLQuery(getEmploymentSQL()).list();
- assertEquals(1, list.size());
- Object[] o = (Object[]) list.get(0);
- assertEquals(8, o.length);
+ list = s.createSQLQuery( getEmploymentSQL() ).list();
+ assertEquals( 1, list.size() );
+ Object[] o = ( Object[] ) list.get( 0 );
+ assertEquals( 8, o.length );
- list = s.createSQLQuery(getEmploymentSQL()).setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP).list();
- assertEquals(1, list.size());
- m = (Map) list.get(0);
- assertTrue(m.containsKey("EMPID"));
- assertTrue(m.containsKey("VALUE"));
- assertTrue(m.containsKey("ENDDATE"));
- assertEquals(8, m.size());
+ list = s.createSQLQuery( getEmploymentSQL() ).setResultTransformer( Transformers.ALIAS_TO_ENTITY_MAP ).list();
+ assertEquals( 1, list.size() );
+ m = ( Map ) list.get( 0 );
+ assertTrue( m.containsKey( "EMPID" ) );
+ assertTrue( m.containsKey( "VALUE" ) );
+ assertTrue( m.containsKey( "ENDDATE" ) );
+ assertEquals( 8, m.size() );
- list = s.createSQLQuery( getEmploymentSQLMixedScalarEntity() ).addScalar( "employerid" ).addEntity( Employment.class ).list();
- assertEquals(1, list.size());
- o = (Object[]) list.get(0);
- assertEquals(2, o.length);
- assertClassAssignability( o[0].getClass(), Number.class);
- assertClassAssignability( o[1].getClass(), Employment.class);
+ list =
+ s.createSQLQuery( getEmploymentSQLMixedScalarEntity() )
+ .addScalar( "employerid" )
+ .addEntity( Employment.class )
+ .list();
+ assertEquals( 1, list.size() );
+ o = ( Object[] ) list.get( 0 );
+ assertEquals( 2, o.length );
+ assertClassAssignability( o[0].getClass(), Number.class );
+ assertClassAssignability( o[1].getClass(), Employment.class );
-
- Query queryWithCollection = s.getNamedQuery("organizationEmploymentsExplicitAliases");
- queryWithCollection.setLong("id", jboss.getId() );
+ Query queryWithCollection = s.getNamedQuery( "organizationEmploymentsExplicitAliases" );
+ queryWithCollection.setLong( "id", jboss.getId() );
list = queryWithCollection.list();
- assertEquals(list.size(),1);
+ assertEquals( list.size(), 1 );
s.clear();
@@ -466,7 +469,7 @@
.addEntity( "org", Organization.class )
.addJoin( "emp", "org.employments" )
.list();
- assertEquals( 2,list.size() );
+ assertEquals( 2, list.size() );
s.clear();
@@ -474,30 +477,30 @@
.addEntity( "org", Organization.class )
.addJoin( "emp", "org.employments" )
.list();
- assertEquals( 2,list.size() );
+ assertEquals( 2, list.size() );
s.clear();
// TODO : why twice?
s.getNamedQuery( "organizationreturnproperty" ).list();
list = s.getNamedQuery( "organizationreturnproperty" ).list();
- assertEquals( 2,list.size() );
+ assertEquals( 2, list.size() );
s.clear();
list = s.getNamedQuery( "organizationautodetect" ).list();
- assertEquals( 2,list.size() );
+ assertEquals( 2, list.size() );
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
- s.delete(emp2);
+ s.delete( emp2 );
- s.delete(jboss);
- s.delete(gavin);
- s.delete(ifa);
+ s.delete( jboss );
+ s.delete( gavin );
+ s.delete( ifa );
t.commit();
s.close();
@@ -505,8 +508,9 @@
t = s.beginTransaction();
Dimension dim = new Dimension( 3, Integer.MAX_VALUE );
s.save( dim );
-// s.flush();
- list = s.createSQLQuery( "select d_len * d_width as surface, d_len * d_width * 10 as volume from Dimension" ).list();
+ list =
+ s.createSQLQuery( "select d_len * d_width as surface, d_len * d_width * 10 as volume from Dimension" )
+ .list();
s.delete( dim );
t.commit();
s.close();
@@ -517,29 +521,17 @@
enterprise.setModel( "USS" );
enterprise.setName( "Entreprise" );
enterprise.setSpeed( 50d );
- Dimension d = new Dimension(45, 10);
+ Dimension d = new Dimension( 45, 10 );
enterprise.setDimensions( d );
s.save( enterprise );
-// s.flush();
- Object[] result = (Object[]) s.getNamedQuery( "spaceship" ).uniqueResult();
- enterprise = (SpaceShip) result[0];
- assertTrue(50d == enterprise.getSpeed() );
+ Object[] result = ( Object[] ) s.getNamedQuery( "spaceship" ).uniqueResult();
+ enterprise = ( SpaceShip ) result[0];
+ assertTrue( 50d == enterprise.getSpeed() );
assertTrue( 450d == extractDoubleValue( result[1] ) );
assertTrue( 4500d == extractDoubleValue( result[2] ) );
- s.delete( dim );
+ s.delete( enterprise );
t.commit();
s.close();
-
- s = openSession();
- t = s.beginTransaction();
- s.delete(emp2);
-
- s.delete(jboss);
- s.delete(gavin);
- s.delete(ifa);
- t.commit();
- s.close();
-
}
public void testMixAndMatchEntityScalar() {
18 years, 4 months
Hibernate SVN: r10400 - branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mixed
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-09-01 14:32:37 -0400 (Fri, 01 Sep 2006)
New Revision: 10400
Modified:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mixed/MixedTest.java
Log:
data cleanup
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mixed/MixedTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mixed/MixedTest.java 2006-09-01 18:31:41 UTC (rev 10399)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mixed/MixedTest.java 2006-09-01 18:32:37 UTC (rev 10400)
@@ -83,7 +83,7 @@
assertNotNull( d2.getCreated() );
assertNotNull( d2.getModified() );
- s.delete( f );
+ s.delete( d.getParent() );
s.delete( d );
s.delete( d2 );
18 years, 4 months
Hibernate SVN: r10399 - branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mixed
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-09-01 14:31:41 -0400 (Fri, 01 Sep 2006)
New Revision: 10399
Modified:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mixed/MixedTest.java
Log:
data cleanup
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mixed/MixedTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mixed/MixedTest.java 2006-09-01 18:31:22 UTC (rev 10398)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/mixed/MixedTest.java 2006-09-01 18:31:41 UTC (rev 10399)
@@ -83,6 +83,7 @@
assertNotNull( d2.getCreated() );
assertNotNull( d2.getModified() );
+ s.delete( f );
s.delete( d );
s.delete( d2 );
18 years, 4 months
Hibernate SVN: r10398 - branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-09-01 14:31:22 -0400 (Fri, 01 Sep 2006)
New Revision: 10398
Modified:
branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java
Log:
cleanup : wow
Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java 2006-09-01 14:37:48 UTC (rev 10397)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/sql/GeneralTest.java 2006-09-01 18:31:22 UTC (rev 10398)
@@ -505,7 +505,6 @@
t = s.beginTransaction();
Dimension dim = new Dimension( 3, Integer.MAX_VALUE );
s.save( dim );
-// s.flush();
list = s.createSQLQuery( "select d_len * d_width as surface, d_len * d_width * 10 as volume from Dimension" ).list();
s.delete( dim );
t.commit();
@@ -520,26 +519,15 @@
Dimension d = new Dimension(45, 10);
enterprise.setDimensions( d );
s.save( enterprise );
-// s.flush();
Object[] result = (Object[]) s.getNamedQuery( "spaceship" ).uniqueResult();
enterprise = (SpaceShip) result[0];
assertTrue(50d == enterprise.getSpeed() );
assertTrue( 450d == extractDoubleValue( result[1] ) );
assertTrue( 4500d == extractDoubleValue( result[2] ) );
- s.delete( dim );
+ s.delete( enterprise );
t.commit();
s.close();
- s = openSession();
- t = s.beginTransaction();
- s.delete(emp2);
-
- s.delete(jboss);
- s.delete(gavin);
- s.delete(ifa);
- t.commit();
- s.close();
-
}
public void testMixAndMatchEntityScalar() {
18 years, 4 months
Hibernate SVN: r10397 - in trunk/Hibernate3/test/org/hibernate/test: . collection collection/map collection/set hql tm
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2006-09-01 10:37:48 -0400 (Fri, 01 Sep 2006)
New Revision: 10397
Added:
trunk/Hibernate3/test/org/hibernate/test/collection/CollectionSuite.java
trunk/Hibernate3/test/org/hibernate/test/collection/map/
trunk/Hibernate3/test/org/hibernate/test/collection/map/Child.java
trunk/Hibernate3/test/org/hibernate/test/collection/map/Mappings.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/collection/map/Parent.java
trunk/Hibernate3/test/org/hibernate/test/collection/map/PersistentMapTest.java
trunk/Hibernate3/test/org/hibernate/test/collection/set/
trunk/Hibernate3/test/org/hibernate/test/collection/set/Child.java
trunk/Hibernate3/test/org/hibernate/test/collection/set/Mappings.hbm.xml
trunk/Hibernate3/test/org/hibernate/test/collection/set/Parent.java
trunk/Hibernate3/test/org/hibernate/test/collection/set/PersistentSetTest.java
Modified:
trunk/Hibernate3/test/org/hibernate/test/AllTests.java
trunk/Hibernate3/test/org/hibernate/test/TestCase.java
trunk/Hibernate3/test/org/hibernate/test/hql/ASTParserLoadingTest.java
trunk/Hibernate3/test/org/hibernate/test/tm/CMTTest.java
Log:
added tests for HHH-1668 (and friends);
cleaned up the skipping stuff
Modified: trunk/Hibernate3/test/org/hibernate/test/AllTests.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/AllTests.java 2006-09-01 13:48:02 UTC (rev 10396)
+++ trunk/Hibernate3/test/org/hibernate/test/AllTests.java 2006-09-01 14:37:48 UTC (rev 10397)
@@ -14,7 +14,7 @@
import org.hibernate.test.cache.CacheSuite;
import org.hibernate.test.cascade.RefreshTest;
import org.hibernate.test.cid.CompositeIdTest;
-import org.hibernate.test.collection.CollectionTest;
+import org.hibernate.test.collection.CollectionSuite;
import org.hibernate.test.component.ComponentTest;
import org.hibernate.test.compositeelement.CompositeElementTest;
import org.hibernate.test.comppropertyref.ComponentPropertyRefTest;
@@ -187,7 +187,7 @@
suite.addTest( IdClassTest.suite() );
suite.addTest( ArrayTest.suite() );
suite.addTest( TernaryTest.suite() );
- suite.addTest( CollectionTest.suite() );
+ suite.addTest( CollectionSuite.suite() );
suite.addTest( IdBagTest.suite() );
suite.addTest( MapCompositeElementTest.suite() );
suite.addTest( MapIndexFormulaTest.suite() );
Modified: trunk/Hibernate3/test/org/hibernate/test/TestCase.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/TestCase.java 2006-09-01 13:48:02 UTC (rev 10396)
+++ trunk/Hibernate3/test/org/hibernate/test/TestCase.java 2006-09-01 14:37:48 UTC (rev 10397)
@@ -28,6 +28,7 @@
import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.dialect.SybaseDialect;
import org.hibernate.dialect.TimesTenDialect;
+import org.hibernate.dialect.DerbyDialect;
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.PersistentClass;
@@ -41,7 +42,7 @@
private static Dialect dialect;
private static Class lastTestClass;
private org.hibernate.classic.Session session;
-
+
protected boolean recreateSchema() {
return true;
}
@@ -147,13 +148,17 @@
return "nonstrict-read-write";
}
+ protected SessionFactoryImplementor sfi() {
+ return ( SessionFactoryImplementor ) getSessions();
+ }
+
protected void setUp() throws Exception {
if ( getSessions()==null || lastTestClass!=getClass() ) {
buildSessionFactory( getMappings() );
lastTestClass = getClass();
}
}
-
+
protected void runTest() throws Throwable {
final boolean stats = ( (SessionFactoryImplementor) sessions ).getStatistics().isStatisticsEnabled();
try {
@@ -171,9 +176,9 @@
}
else {
session=null;
-
+
//assertAllDataRemoved();
-
+
}
}
catch (Throwable e) {
@@ -195,34 +200,64 @@
}
}
+ public void runBare() throws Throwable {
+ String sysPropName = "hibernate.test.validatefailureexpected";
+ assertNotNull( getName() );
+ if ( Boolean.getBoolean( sysPropName ) ) {
+ if ( getName().endsWith( "FailureExpected" ) ) {
+ Throwable t = null;
+ try {
+ super.runBare();
+ }
+ catch ( Throwable afe ) {
+ t = afe;
+ }
+ if ( t == null ) {
+ fail( "Test where marked as FailureExpected, but did not fail!" );
+ }
+ else {
+ reportSkip( "ignoring *FailuredExpected methods", "Failed with: " + t.toString() );
+ }
+ }
+ else {
+ super.runBare();
+ }
+ }
+ else {
+ super.runBare();
+ }
+ }
+
protected void assertAllDataRemoved() {
- if(!recreateSchema()) {
+ if ( !recreateSchema() ) {
return; // no tables were created...
}
-
+
Session tmpSession = openSession();
List list = tmpSession.createQuery( "from java.lang.Object" ).list();
-
+
StringBuffer sb = new StringBuffer();
Map items = new HashMap();
-
- if(!list.isEmpty()) {
- for (Iterator iter = list.iterator(); iter.hasNext();) {
+
+ if ( !list.isEmpty() ) {
+ for ( Iterator iter = list.iterator(); iter.hasNext(); ) {
Object element = iter.next();
- Integer l = (Integer) items.get(tmpSession.getEntityName( element ));
- if(l==null) {
- l = new Integer(0);
+ Integer l = ( Integer ) items.get( tmpSession.getEntityName( element ) );
+ if ( l == null ) {
+ l = new Integer( 0 );
}
- l = new Integer(l.intValue()+1);
- items.put(tmpSession.getEntityName( element ), l);
- System.out.println("Data left: " + element);
+ l = new Integer( l.intValue() + 1 );
+ items.put( tmpSession.getEntityName( element ), l );
+ System.out.println( "Data left: " + element );
}
try {
tmpSession.close();
- } finally {
- fail("Data is left in the database: " + items.toString() );
}
- } else {
+ finally {
+ fail( "Data is left in the database: " + items.toString() );
+ }
+ }
+ else {
tmpSession.close();
}
}
@@ -291,6 +326,9 @@
}
}
+
+ // test skipping ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
/**
* Intended to indicate that this test class as a whole is intended for
* a dialect or series of dialects. Skips here (appliesTo = false), therefore
@@ -332,35 +370,62 @@
}
}
- protected boolean dialectSupportsEmptyInList(String testdescription) {
- return reportSkip( "Dialect does not support SQL: \'x in ()\'.", testdescription, dialectIsNot(new Class[] {
- Oracle9Dialect.class,
- MySQLDialect.class,
- DB2Dialect.class,
- HSQLDialect.class,
- SQLServerDialect.class,
- SybaseDialect.class,
- PostgreSQLDialect.class,
- TimesTenDialect.class
- } ));
+ protected boolean allowsPhysicalColumnNameInOrderby(String testDescription) {
+ if ( DerbyDialect.class.isInstance( getDialect() ) ) {
+ reportSkip( "Dialect does not support physical column name in order-by clause after it is aliased", testDescription );
+ return false;
+ }
+ return true;
}
- protected boolean dialectIsCaseSensitive(String testdescription) {
- // MySQL and SQLServer is case insensitive on strings (at least in default installation)
- return reportSkip( "Dialect is case sensitive. ", testdescription, dialectIsNot(new Class[] { MySQLDialect.class, SQLServerDialect.class }));
+ protected boolean allowsPhysicalColumnNameInHaving(String testDescription) {
+ if ( DerbyDialect.class.isInstance( getDialect() ) ) {
+ reportSkip( "Dialect does not support physical column name in having clause after it is aliased", testDescription );
+ return false;
+ }
+ return true;
}
- protected boolean reportSkip(String reason, String testDescription, boolean canDoIt) {
+ protected boolean dialectSupportsEmptyInList(String testDescription) {
+ boolean canDoIt = dialectIsNot(
+ new Class[] {
+ Oracle9Dialect.class,
+ MySQLDialect.class,
+ DB2Dialect.class,
+ HSQLDialect.class,
+ SQLServerDialect.class,
+ SybaseDialect.class,
+ PostgreSQLDialect.class,
+ TimesTenDialect.class
+ }
+ );
+
if ( !canDoIt ) {
- reportSkip( reason, testDescription );
+ reportSkip( "Dialect does not support SQL: \'x in ()\'.", testDescription );
}
return canDoIt;
}
+ protected boolean dialectIsCaseSensitive(String testDescription) {
+ // MySQL and SQLServer is case insensitive on strings (at least in default installation)
+ boolean canDoIt = dialectIsNot(
+ new Class[] { MySQLDialect.class, SQLServerDialect.class }
+ );
+
+ if ( !canDoIt ) {
+ reportSkip( "Dialect is case sensitive. ", testDescription );
+ }
+ return canDoIt;
+ }
+
protected void reportSkip(String reason, String testDescription) {
SKIP_LOG.warn( "*** skipping [" + fullTestName() + "] - " + testDescription + " : " + reason, new Exception() );
}
+ public String fullTestName() {
+ return this.getName() + " (" + this.getClass().getName() + ")";
+ }
+
private boolean dialectIsNot(Class[] dialectClasses) {
for (int i = 0; i < dialectClasses.length; i++) {
Class dialectClass = dialectClasses[i];
@@ -371,35 +436,4 @@
return true;
}
- public String fullTestName() {
- return this.getName() + " (" + this.getClass().getName() + ")";
- }
-
- protected SessionFactoryImplementor sfi() {
- return ( SessionFactoryImplementor ) getSessions();
- }
-
- public void runBare() throws Throwable {
- assertNotNull(getName());
- String string = "hibernate.test.validatefailureexpected";
- if(Boolean.getBoolean( string )) {
- if(getName().endsWith( "FailureExpected" ) ) {
- Throwable t = null;
- try {
- super.runBare();
- } catch(Throwable afe) {
- t = afe;
- }
- if(t==null) {
- fail("Test where marked as FailureExpected, but did not fail!");
- } else {
- reportSkip( "ignoring *FailuredExpected methods", "Failed with: " + t.toString() );
- }
- } else {
- super.runBare();
- }
- } else {
- super.runBare();
- }
- }
}
\ No newline at end of file
Added: trunk/Hibernate3/test/org/hibernate/test/collection/CollectionSuite.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/collection/CollectionSuite.java 2006-09-01 13:48:02 UTC (rev 10396)
+++ trunk/Hibernate3/test/org/hibernate/test/collection/CollectionSuite.java 2006-09-01 14:37:48 UTC (rev 10397)
@@ -0,0 +1,23 @@
+package org.hibernate.test.collection;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.hibernate.test.collection.map.PersistentMapTest;
+import org.hibernate.test.collection.set.PersistentSetTest;
+
+/**
+ * todo: describe CollectionSuite
+ *
+ * @author Steve Ebersole
+ */
+public class CollectionSuite {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite( "Collection-related tests" );
+ suite.addTest( CollectionTest.suite() );
+ suite.addTest( PersistentMapTest.suite() );
+ suite.addTest( PersistentSetTest.suite() );
+ return suite;
+ }
+
+}
Added: trunk/Hibernate3/test/org/hibernate/test/collection/map/Child.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/collection/map/Child.java 2006-09-01 13:48:02 UTC (rev 10396)
+++ trunk/Hibernate3/test/org/hibernate/test/collection/map/Child.java 2006-09-01 14:37:48 UTC (rev 10397)
@@ -0,0 +1,34 @@
+package org.hibernate.test.collection.map;
+
+/**
+ * todo: describe Child
+ *
+ * @author Steve Ebersole
+ */
+public class Child {
+ private String name;
+ private Parent parent;
+
+ public Child() {
+ }
+
+ public Child(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Parent getParent() {
+ return parent;
+ }
+
+ public void setParent(Parent parent) {
+ this.parent = parent;
+ }
+}
Added: trunk/Hibernate3/test/org/hibernate/test/collection/map/Mappings.hbm.xml
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/collection/map/Mappings.hbm.xml 2006-09-01 13:48:02 UTC (rev 10396)
+++ trunk/Hibernate3/test/org/hibernate/test/collection/map/Mappings.hbm.xml 2006-09-01 14:37:48 UTC (rev 10397)
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+
+<hibernate-mapping package="org.hibernate.test.collection.map">
+
+ <class name="Parent">
+ <id name="name" column="NAME" type="string" />
+
+ <map name="children" inverse="true" cascade="all">
+ <key column="PARENT" />
+ <map-key type="string" />
+ <one-to-many class="Child" />
+ </map>
+ </class>
+
+ <class name="Child">
+ <id name="name" column="NAME" type="string"/>
+ <many-to-one name="parent" class="Parent" cascade="none" />
+ </class>
+
+</hibernate-mapping>
Added: trunk/Hibernate3/test/org/hibernate/test/collection/map/Parent.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/collection/map/Parent.java 2006-09-01 13:48:02 UTC (rev 10396)
+++ trunk/Hibernate3/test/org/hibernate/test/collection/map/Parent.java 2006-09-01 14:37:48 UTC (rev 10397)
@@ -0,0 +1,37 @@
+package org.hibernate.test.collection.map;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * todo: describe Parent
+ *
+ * @author Steve Ebersole
+ */
+public class Parent {
+ private String name;
+ private Map children = new HashMap();
+
+ public Parent() {
+ }
+
+ public Parent(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Map getChildren() {
+ return children;
+ }
+
+ public void setChildren(Map children) {
+ this.children = children;
+ }
+}
Added: trunk/Hibernate3/test/org/hibernate/test/collection/map/PersistentMapTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/collection/map/PersistentMapTest.java 2006-09-01 13:48:02 UTC (rev 10396)
+++ trunk/Hibernate3/test/org/hibernate/test/collection/map/PersistentMapTest.java 2006-09-01 14:37:48 UTC (rev 10397)
@@ -0,0 +1,75 @@
+package org.hibernate.test.collection.map;
+
+import org.hibernate.test.TestCase;
+import org.hibernate.Session;
+import org.hibernate.collection.PersistentMap;
+
+import java.util.HashMap;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * todo: describe PersistentMapTest
+ *
+ * @author Steve Ebersole
+ */
+public class PersistentMapTest extends TestCase {
+ public PersistentMapTest(String name) {
+ super( name );
+ }
+
+ protected String[] getMappings() {
+ return new String[] { "collection/map/Mappings.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new TestSuite( PersistentMapTest.class );
+ }
+
+ public void testWriteMethodDirtying() {
+ Parent parent = new Parent( "p1" );
+ Child child = new Child( "c1" );
+ parent.getChildren().put( child.getName(), child );
+ child.setParent( parent );
+ Child otherChild = new Child( "c2" );
+
+ Session session = openSession();
+ session.beginTransaction();
+ session.save( parent );
+ session.flush();
+ // at this point, the set on parent has now been replaced with a PersistentSet...
+ PersistentMap children = ( PersistentMap ) parent.getChildren();
+
+ Object old = children.put( child.getName(), child );
+ assertTrue( old == child );
+ assertFalse( children.isDirty() );
+
+ old = children.remove( otherChild.getName() );
+ assertNull( old );
+ assertFalse( children.isDirty() );
+
+ HashMap otherMap = new HashMap();
+ otherMap.put( child.getName(), child );
+ children.putAll( otherMap );
+ assertFalse( children.isDirty() );
+
+ otherMap = new HashMap();
+ otherMap.put( otherChild.getName(), otherChild );
+ children.putAll( otherMap );
+ assertTrue( children.isDirty() );
+
+ children.clearDirty();
+ session.delete( child );
+ children.clear();
+ assertTrue( children.isDirty() );
+ session.flush();
+
+ children.clear();
+ assertFalse( children.isDirty() );
+
+ session.delete( parent );
+ session.getTransaction().commit();
+ session.close();
+ }
+}
Added: trunk/Hibernate3/test/org/hibernate/test/collection/set/Child.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/collection/set/Child.java 2006-09-01 13:48:02 UTC (rev 10396)
+++ trunk/Hibernate3/test/org/hibernate/test/collection/set/Child.java 2006-09-01 14:37:48 UTC (rev 10397)
@@ -0,0 +1,34 @@
+package org.hibernate.test.collection.set;
+
+/**
+ * todo: describe Child
+ *
+ * @author Steve Ebersole
+ */
+public class Child {
+ private String name;
+ private Parent parent;
+
+ public Child() {
+ }
+
+ public Child(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Parent getParent() {
+ return parent;
+ }
+
+ public void setParent(Parent parent) {
+ this.parent = parent;
+ }
+}
Added: trunk/Hibernate3/test/org/hibernate/test/collection/set/Mappings.hbm.xml
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/collection/set/Mappings.hbm.xml 2006-09-01 13:48:02 UTC (rev 10396)
+++ trunk/Hibernate3/test/org/hibernate/test/collection/set/Mappings.hbm.xml 2006-09-01 14:37:48 UTC (rev 10397)
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+
+<hibernate-mapping package="org.hibernate.test.collection.set">
+
+ <class name="Parent">
+ <id name="name" column="NAME" type="string" />
+
+ <set name="children" inverse="true" cascade="all">
+ <key column="PARENT" />
+ <one-to-many class="Child" />
+ </set>
+ </class>
+
+ <class name="Child">
+ <id name="name" column="NAME" type="string"/>
+ <many-to-one name="parent" class="Parent" cascade="none" />
+ </class>
+
+</hibernate-mapping>
Added: trunk/Hibernate3/test/org/hibernate/test/collection/set/Parent.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/collection/set/Parent.java 2006-09-01 13:48:02 UTC (rev 10396)
+++ trunk/Hibernate3/test/org/hibernate/test/collection/set/Parent.java 2006-09-01 14:37:48 UTC (rev 10397)
@@ -0,0 +1,37 @@
+package org.hibernate.test.collection.set;
+
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * todo: describe Parent
+ *
+ * @author Steve Ebersole
+ */
+public class Parent {
+ private String name;
+ private Set children = new HashSet();
+
+ public Parent() {
+ }
+
+ public Parent(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Set getChildren() {
+ return children;
+ }
+
+ public void setChildren(Set children) {
+ this.children = children;
+ }
+}
Added: trunk/Hibernate3/test/org/hibernate/test/collection/set/PersistentSetTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/collection/set/PersistentSetTest.java 2006-09-01 13:48:02 UTC (rev 10396)
+++ trunk/Hibernate3/test/org/hibernate/test/collection/set/PersistentSetTest.java 2006-09-01 14:37:48 UTC (rev 10397)
@@ -0,0 +1,76 @@
+package org.hibernate.test.collection.set;
+
+import org.hibernate.test.TestCase;
+import org.hibernate.Session;
+import org.hibernate.collection.PersistentSet;
+
+import java.util.HashSet;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * todo: describe PersistentSetTest
+ *
+ * @author Steve Ebersole
+ */
+public class PersistentSetTest extends TestCase {
+ public PersistentSetTest(String name) {
+ super( name );
+ }
+
+ protected String[] getMappings() {
+ return new String[] { "collection/set/Mappings.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new TestSuite( PersistentSetTest.class );
+ }
+
+ public void testWriteMethodDirtying() {
+ Parent parent = new Parent( "p1" );
+ Child child = new Child( "c1" );
+ parent.getChildren().add( child );
+ child.setParent( parent );
+ Child otherChild = new Child( "c2" );
+
+ Session session = openSession();
+ session.beginTransaction();
+ session.save( parent );
+ session.flush();
+ // at this point, the set on parent has now been replaced with a PersistentSet...
+ PersistentSet children = ( PersistentSet ) parent.getChildren();
+
+ assertFalse( children.add( child ) );
+ assertFalse( children.isDirty() );
+
+ assertFalse( children.remove( otherChild ) );
+ assertFalse( children.isDirty() );
+
+ HashSet otherSet = new HashSet();
+ otherSet.add( child );
+ assertFalse( children.addAll( otherSet ) );
+ assertFalse( children.isDirty() );
+
+ assertFalse( children.retainAll( otherSet ) );
+ assertFalse( children.isDirty() );
+
+ otherSet = new HashSet();
+ otherSet.add( otherChild );
+ assertFalse( children.removeAll( otherSet ) );
+ assertFalse( children.isDirty() );
+
+ children.clear();
+ session.delete( child );
+ assertTrue( children.isDirty() );
+
+ session.flush();
+
+ children.clear();
+ assertFalse( children.isDirty() );
+
+ session.delete( parent );
+ session.getTransaction().commit();
+ session.close();
+ }
+}
Modified: trunk/Hibernate3/test/org/hibernate/test/hql/ASTParserLoadingTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/hql/ASTParserLoadingTest.java 2006-09-01 13:48:02 UTC (rev 10396)
+++ trunk/Hibernate3/test/org/hibernate/test/hql/ASTParserLoadingTest.java 2006-09-01 14:37:48 UTC (rev 10397)
@@ -89,6 +89,79 @@
}
+ public void testSelectAndResultColumnReferences() {
+ Session s = openSession();
+ s.beginTransaction();
+ s.createQuery( "select m.name from Model as m" ).list();
+ s.createQuery( "select h.name.first from Human h" ).list();
+ s.createQuery( "select h.name from Human h" ).list();
+ s.getTransaction().commit();
+ s.close();
+ }
+
+ public void testSelectAndResultColumnReferencesWithGrouping() {
+ if ( ! allowsPhysicalColumnNameInHaving( "scalar HQL queries" ) ) {
+ return;
+ }
+
+ Session s = openSession();
+ s.beginTransaction();
+
+ s.createQuery( "select m.name, count(*) from Model as m group by m.name" ).list();
+ s.createQuery( "select m.name, count(*) from Model as m group by m.name order by m.name" ).list();
+ s.createQuery( "select m.name, max( m.id ) from Model as m group by m.name having max( id ) > 1" ).list();
+ s.createQuery( "select m.name, count(*) from Model as m group by m.name having count(*) > 1" ).list();
+ s.createQuery( "select m.name, count(*) from Model as m group by m.name having m.name like 'abc%'" ).list();
+
+ s.createQuery( "select h.name.first, count(*) from Human h group by h.name.first" ).list();
+ s.createQuery( "select h.name.first, count(*) from Human h group by h.name.first having count(*) > 1" ).list();
+
+ s.createQuery( "select h.name, count(*) from Human h group by h.name" ).list();
+ s.createQuery( "select h.name, count(*) from Human h group by h.name having count(*) > 1" ).list();
+
+ s.getTransaction().commit();
+ s.close();
+ }
+
+ public void testSelectAndResultColumnReferencesWithCollation() {
+ if ( ! allowsPhysicalColumnNameInOrderby( "scalar HQL queries" ) ) {
+ return;
+ }
+
+ Session s = openSession();
+ s.beginTransaction();
+
+ s.createQuery( "select m.name from Model as m order by m.name" ).list();
+
+ s.createQuery( "select h.name.first from Human h order by h.name.first" ).list();
+
+ s.createQuery( "select h.name from Human h order by h.name" ).list();
+
+ s.getTransaction().commit();
+ s.close();
+ }
+
+ public void testSelectAndResultColumnReferencesWithCollationAndOrdering() {
+ if ( ! allowsPhysicalColumnNameInHaving( "scalar HQL queries" ) ) {
+ return;
+ }
+ if ( ! allowsPhysicalColumnNameInOrderby( "scalar HQL queries" ) ) {
+ return;
+ }
+
+ Session s = openSession();
+ s.beginTransaction();
+
+ s.createQuery( "select m.name, count(*) from Model as m group by m.name having m.name like 'abc%' order by m.name" ).list();
+
+ s.createQuery( "select h.name.first, count(*) from Human h group by h.name.first having count(*) > 1 order by h.name.first" ).list();
+
+ s.createQuery( "select h.name, count(*) from Human h group by h.name having count(*) > 1 order by h.name" ).list();
+
+ s.getTransaction().commit();
+ s.close();
+ }
+
public void testJPAPositionalParameterList() {
Session s = openSession();
s.beginTransaction();
Modified: trunk/Hibernate3/test/org/hibernate/test/tm/CMTTest.java
===================================================================
--- trunk/Hibernate3/test/org/hibernate/test/tm/CMTTest.java 2006-09-01 13:48:02 UTC (rev 10396)
+++ trunk/Hibernate3/test/org/hibernate/test/tm/CMTTest.java 2006-09-01 14:37:48 UTC (rev 10397)
@@ -185,10 +185,12 @@
}
public void testConcurrentCachedDirtyQueries() throws Exception {
- if ( reportSkip( "dead-lock bug", "concurrent queries", getDialect() instanceof SybaseDialect ) ) {
+ if ( getDialect() instanceof SybaseDialect ) {
// sybase and sqlserver have serious locking issues here...
+ reportSkip( "dead-lock bug", "concurrent queries" );
return;
}
+
DummyTransactionManager.INSTANCE.begin();
Session s = openSession();
Map foo = new HashMap();
18 years, 4 months