diff --git a/hibernate-core/src/main/java/org/hibernate/sql/Template.java b/hibernate-core/src/main/java/org/hibernate/sql/Template.java
index 7a6ddce353..1335caec9c 100644
--- a/hibernate-core/src/main/java/org/hibernate/sql/Template.java
+++ b/hibernate-core/src/main/java/org/hibernate/sql/Template.java
@@ -13,6 +13,8 @@ import java.util.Locale;
import java.util.Set;
import java.util.StringTokenizer;
+import com.sun.org.apache.xpath.internal.operations.Bool;
+
import org.hibernate.HibernateException;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.function.SQLFunction;
@@ -25,6 +27,8 @@ import org.hibernate.sql.ordering.antlr.OrderByFragmentTranslator;
import org.hibernate.sql.ordering.antlr.OrderByTranslation;
import org.hibernate.sql.ordering.antlr.SqlValueReference;
import org.hibernate.sql.ordering.antlr.TranslationContext;
+import org.hibernate.type.BooleanType;
+import org.hibernate.type.Type;
/**
* Parses SQL fragments specified in mapping documents
@@ -305,6 +309,9 @@ public final class Template {
else if ( inFromClause && ",".equals(lcToken) ) {
beforeTable = true;
}
+ if ( isBoolean( token ) ) {
+ token = dialect.toBooleanValueString( Boolean.parseBoolean( token ) );
+ }
result.append(token);
}
@@ -712,7 +719,7 @@ public final class Template {
}
private static boolean isNamedParameter(String token) {
- return token.startsWith(":");
+ return token.startsWith( ":" );
}
private static boolean isFunctionOrKeyword(String lcToken, String nextToken, Dialect dialect, SQLFunctionRegistry functionRegistry) {
@@ -740,10 +747,16 @@ public final class Template {
}
private static boolean isIdentifier(String token) {
- return token.charAt(0)=='`' || ( //allow any identifier quoted with backtick
- Character.isLetter( token.charAt(0) ) && //only recognizes identifiers beginning with a letter
- token.indexOf('.') < 0
+ if ( isBoolean( token ) ) {
+ return false;
+ }
+ return token.charAt( 0 ) == '`' || ( //allow any identifier quoted with backtick
+ Character.isLetter( token.charAt( 0 ) ) && //only recognizes identifiers beginning with a letter
+ token.indexOf( '.' ) < 0
);
}
+ private static boolean isBoolean(String token) {
+ return "true".equals( token ) || "false".equals( token );
+ }
}
diff --git a/hibernate-core/src/test/java/org/hibernate/test/bidi/Auction.hbm.xml b/hibernate-core/src/test/java/org/hibernate/test/bidi/Auction.hbm.xml
index 4c0ba3b9f2..537da2460b 100755
--- a/hibernate-core/src/test/java/org/hibernate/test/bidi/Auction.hbm.xml
+++ b/hibernate-core/src/test/java/org/hibernate/test/bidi/Auction.hbm.xml
@@ -26,7 +26,7 @@
id
- 1
+ true
diff --git a/hibernate-core/src/test/java/org/hibernate/test/formulajoin/Master.hbm.xml b/hibernate-core/src/test/java/org/hibernate/test/formulajoin/Master.hbm.xml
index f4f0875190..64217e528f 100755
--- a/hibernate-core/src/test/java/org/hibernate/test/formulajoin/Master.hbm.xml
+++ b/hibernate-core/src/test/java/org/hibernate/test/formulajoin/Master.hbm.xml
@@ -34,7 +34,7 @@
insert="false"
update="false">
- 1
+ true