|
13 | 13 | import java.util.Set; |
14 | 14 | import java.util.StringTokenizer; |
15 | 15 |
|
| 16 | +import com.sun.org.apache.xpath.internal.operations.Bool; |
| 17 | + |
16 | 18 | import org.hibernate.HibernateException; |
17 | 19 | import org.hibernate.dialect.Dialect; |
18 | 20 | import org.hibernate.dialect.function.SQLFunction; |
|
25 | 27 | import org.hibernate.sql.ordering.antlr.OrderByTranslation; |
26 | 28 | import org.hibernate.sql.ordering.antlr.SqlValueReference; |
27 | 29 | import org.hibernate.sql.ordering.antlr.TranslationContext; |
| 30 | +import org.hibernate.type.BooleanType; |
| 31 | +import org.hibernate.type.Type; |
28 | 32 |
|
29 | 33 | /** |
30 | 34 | * Parses SQL fragments specified in mapping documents |
@@ -305,6 +309,9 @@ else if ( isIdentifier(token) |
305 | 309 | else if ( inFromClause && ",".equals(lcToken) ) { |
306 | 310 | beforeTable = true; |
307 | 311 | } |
| 312 | + if ( isBoolean( token ) ) { |
| 313 | + token = dialect.toBooleanValueString( Boolean.parseBoolean( token ) ); |
| 314 | + } |
308 | 315 | result.append(token); |
309 | 316 | } |
310 | 317 |
|
@@ -712,7 +719,7 @@ public ColumnMapper getColumnMapper() { |
712 | 719 | } |
713 | 720 |
|
714 | 721 | private static boolean isNamedParameter(String token) { |
715 | | - return token.startsWith(":"); |
| 722 | + return token.startsWith( ":" ); |
716 | 723 | } |
717 | 724 |
|
718 | 725 | private static boolean isFunctionOrKeyword(String lcToken, String nextToken, Dialect dialect, SQLFunctionRegistry functionRegistry) { |
@@ -740,10 +747,16 @@ private static boolean isFunction(String lcToken, String nextToken, SQLFunctionR |
740 | 747 | } |
741 | 748 |
|
742 | 749 | private static boolean isIdentifier(String token) { |
743 | | - return token.charAt(0)=='`' || ( //allow any identifier quoted with backtick |
744 | | - Character.isLetter( token.charAt(0) ) && //only recognizes identifiers beginning with a letter |
745 | | - token.indexOf('.') < 0 |
| 750 | + if ( isBoolean( token ) ) { |
| 751 | + return false; |
| 752 | + } |
| 753 | + return token.charAt( 0 ) == '`' || ( //allow any identifier quoted with backtick |
| 754 | + Character.isLetter( token.charAt( 0 ) ) && //only recognizes identifiers beginning with a letter |
| 755 | + token.indexOf( '.' ) < 0 |
746 | 756 | ); |
747 | 757 | } |
748 | 758 |
|
| 759 | + private static boolean isBoolean(String token) { |
| 760 | + return "true".equals( token ) || "false".equals( token ); |
| 761 | + } |
749 | 762 | } |
0 commit comments