[hibernate-commits] Hibernate SVN: r11359 - branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Thu Mar 29 08:35:51 EDT 2007


Author: steve.ebersole at jboss.com
Date: 2007-03-29 08:35:51 -0400 (Thu, 29 Mar 2007)
New Revision: 11359

Modified:
   branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/LegacyTestCase.java
Log:
test suite fixes : postgresql (boolean handling)

Modified: branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/LegacyTestCase.java
===================================================================
--- branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/LegacyTestCase.java	2007-03-29 01:45:07 UTC (rev 11358)
+++ branches/Branch_3_2/Hibernate3/test/org/hibernate/test/legacy/LegacyTestCase.java	2007-03-29 12:35:51 UTC (rev 11359)
@@ -5,6 +5,7 @@
 import org.hibernate.hql.classic.ClassicQueryTranslatorFactory;
 import org.hibernate.util.StringHelper;
 import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.dialect.Dialect;
 
 /**
  * @author Steve Ebersole
@@ -32,14 +33,25 @@
 		super.configure( cfg );
 		if ( !useAntlrParser ) {
 			cfg.setProperty( Environment.QUERY_TRANSLATOR, ClassicQueryTranslatorFactory.class.getName() );
-			String subs = cfg.getProperties().getProperty( Environment.QUERY_SUBSTITUTIONS );
-			if ( StringHelper.isEmpty( subs ) ) {
-				subs = "true=1, false=0";
+			try {
+				String dialectTrueRepresentation = Dialect.getDialect().toBooleanValueString( true );
+				// if this call succeeds, then the dialect is saying to represent true/false as int values...
+				Integer.parseInt( dialectTrueRepresentation );
+				String subs = cfg.getProperties().getProperty( Environment.QUERY_SUBSTITUTIONS );
+				if ( subs == null ) {
+					subs = "";
+				}
+				if ( StringHelper.isEmpty( subs ) ) {
+					subs = "true=1, false=0";
+				}
+				else {
+					subs += ", true=1, false=0";
+				}
+				cfg.getProperties().setProperty( Environment.QUERY_SUBSTITUTIONS, subs );
 			}
-			else {
-				subs += ", true=1, false=0";
+			catch( NumberFormatException nfe ) {
+				// the Integer#parseInt call failed...
 			}
-			cfg.getProperties().setProperty( Environment.QUERY_SUBSTITUTIONS, subs );
 		}
 	}
 }




More information about the hibernate-commits mailing list