[hibernate-commits] Hibernate SVN: r18545 - core/trunk/core/src/main/java/org/hibernate/hql/ast/util.
hibernate-commits at lists.jboss.org
hibernate-commits at lists.jboss.org
Wed Jan 13 15:32:33 EST 2010
Author: steve.ebersole at jboss.com
Date: 2010-01-13 15:32:33 -0500 (Wed, 13 Jan 2010)
New Revision: 18545
Modified:
core/trunk/core/src/main/java/org/hibernate/hql/ast/util/LiteralProcessor.java
Log:
HHH-4780 - Allow BigDecimal and BigInteger to be specified as numeric literal types
Modified: core/trunk/core/src/main/java/org/hibernate/hql/ast/util/LiteralProcessor.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/hql/ast/util/LiteralProcessor.java 2010-01-13 19:45:07 UTC (rev 18544)
+++ core/trunk/core/src/main/java/org/hibernate/hql/ast/util/LiteralProcessor.java 2010-01-13 20:32:33 UTC (rev 18545)
@@ -247,6 +247,13 @@
private String determineIntegerRepresentation(String text, int type) {
try {
+ if ( type == NUM_BIG_INTEGER ) {
+ String literalValue = text;
+ if ( literalValue.endsWith( "bi" ) || literalValue.endsWith( "BI" ) ) {
+ literalValue = literalValue.substring( 0, literalValue.length() - 2 );
+ }
+ return new BigInteger( literalValue ).toString();
+ }
if ( type == NUM_INT ) {
try {
return Integer.valueOf( text ).toString();
@@ -255,21 +262,11 @@
log.trace( "could not format incoming text [" + text + "] as a NUM_INT; assuming numeric overflow and attempting as NUM_LONG" );
}
}
- else if ( type == NUM_LONG ) {
- String literalValue = text;
- if ( literalValue.endsWith( "l" ) || literalValue.endsWith( "L" ) ) {
- literalValue = literalValue.substring( 0, literalValue.length() - 1 );
- }
- return Long.valueOf( literalValue ).toString();
+ String literalValue = text;
+ if ( literalValue.endsWith( "l" ) || literalValue.endsWith( "L" ) ) {
+ literalValue = literalValue.substring( 0, literalValue.length() - 1 );
}
- else if ( type == NUM_BIG_INTEGER ) {
- String literalValue = text;
- if ( literalValue.endsWith( "bi" ) || literalValue.endsWith( "BI" ) ) {
- literalValue = literalValue.substring( 0, literalValue.length() - 2 );
- }
- return new BigInteger( literalValue ).toString();
- }
- throw new HibernateException( "Unknown literal type to parse as integer" );
+ return Long.valueOf( literalValue ).toString();
}
catch( Throwable t ) {
throw new HibernateException( "Could not parse literal [" + text + "] as integer", t );
More information about the hibernate-commits
mailing list