[hibernate-commits] Hibernate SVN: r19853 - core/branches/Branch_3_5/core/src/main/java/org/hibernate/dialect.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Tue Jun 29 03:25:17 EDT 2010
Author: stliu
Date: 2010-06-29 03:25:17 -0400 (Tue, 29 Jun 2010)
New Revision: 19853
Modified:
core/branches/Branch_3_5/core/src/main/java/org/hibernate/dialect/Ingres10Dialect.java
Log:
HHH-5213 Add native SQL Boolean type to Ingres10Dialect
Modified: core/branches/Branch_3_5/core/src/main/java/org/hibernate/dialect/Ingres10Dialect.java
===================================================================
--- core/branches/Branch_3_5/core/src/main/java/org/hibernate/dialect/Ingres10Dialect.java 2010-06-29 07:24:22 UTC (rev 19852)
+++ core/branches/Branch_3_5/core/src/main/java/org/hibernate/dialect/Ingres10Dialect.java 2010-06-29 07:25:17 UTC (rev 19853)
@@ -1,6 +1,7 @@
package org.hibernate.dialect;
import java.sql.Types;
+import java.util.Properties;
import org.hibernate.Hibernate;
import org.hibernate.cfg.Environment;
@@ -8,9 +9,10 @@
/**
* A SQL dialect for Ingres 10 and later versions.
- *
+ * <p/>
* Changes:
* <ul>
+ * <li>Add native BOOLEAN type support</li>
* </ul>
*
* @author Raymond Fan
@@ -18,5 +20,39 @@
public class Ingres10Dialect extends Ingres9Dialect {
public Ingres10Dialect() {
super();
+ registerBooleanSupport();
}
+
+ // Boolean column type support
+
+ /**
+ * The SQL literal value to which this database maps boolean values.
+ *
+ * @param bool The boolean value
+ * @return The appropriate SQL literal.
+ */
+ public String toBooleanValueString(boolean bool) {
+ return bool ? "true" : "false";
+ }
+
+ protected void registerBooleanSupport() {
+ // Column type
+
+ // Boolean type (mapping/BooleanType) mapping maps SQL BIT to Java
+ // Boolean. In order to create a boolean column, BIT needs to be mapped
+ // to boolean as well, similar to H2Dialect.
+ registerColumnType( Types.BIT, "boolean" );
+ registerColumnType( Types.BOOLEAN, "boolean" );
+
+ // Functions
+
+ // true, false and unknown are now valid values
+ // Remove the query substitutions previously added in IngresDialect.
+ Properties properties = getDefaultProperties();
+ String querySubst = properties.getProperty(Environment.QUERY_SUBSTITUTIONS);
+ if (querySubst != null) {
+ String newQuerySubst = querySubst.replace("true=1,false=0","");
+ properties.setProperty(Environment.QUERY_SUBSTITUTIONS, newQuerySubst);
+ }
+ }
}
More information about the hibernate-commits
mailing list