HHH-4743 - Bug in BooleanLiteralNode with CustomType

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@18491 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Steve Ebersole 2010-01-09 20:17:47 +00:00
parent 0f96757d1a
commit 49a37c3165
1 changed files with 13 additions and 9 deletions

View File

@ -24,8 +24,8 @@
*/ */
package org.hibernate.hql.ast.tree; package org.hibernate.hql.ast.tree;
import org.hibernate.type.LiteralType;
import org.hibernate.type.Type; import org.hibernate.type.Type;
import org.hibernate.type.BooleanType;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.QueryException; import org.hibernate.QueryException;
import org.hibernate.engine.SessionFactoryImplementor; import org.hibernate.engine.SessionFactoryImplementor;
@ -42,33 +42,37 @@ public class BooleanLiteralNode extends LiteralNode implements ExpectedTypeAware
return expectedType == null ? Hibernate.BOOLEAN : expectedType; return expectedType == null ? Hibernate.BOOLEAN : expectedType;
} }
public BooleanType getTypeInternal() {
return ( BooleanType ) getDataType();
}
public Boolean getValue() { public Boolean getValue() {
return getType() == TRUE ? Boolean.TRUE : Boolean.FALSE; return getType() == TRUE ? Boolean.TRUE : Boolean.FALSE;
} }
/** /**
* Expected-types really only pertinent here for boolean literals... * {@inheritDoc}
*
* @param expectedType
*/ */
public void setExpectedType(Type expectedType) { public void setExpectedType(Type expectedType) {
this.expectedType = expectedType; this.expectedType = expectedType;
} }
/**
* {@inheritDoc}
*/
public Type getExpectedType() { public Type getExpectedType() {
return expectedType; return expectedType;
} }
/**
* {@inheritDoc}
*/
public String getRenderText(SessionFactoryImplementor sessionFactory) { public String getRenderText(SessionFactoryImplementor sessionFactory) {
try { try {
return getTypeInternal().objectToSQLString( getValue(), sessionFactory.getDialect() ); return typeAsLiteralType().objectToSQLString( getValue(), sessionFactory.getDialect() );
} }
catch( Throwable t ) { catch( Throwable t ) {
throw new QueryException( "Unable to render boolean literal value", t ); throw new QueryException( "Unable to render boolean literal value", t );
} }
} }
private LiteralType typeAsLiteralType() {
return (LiteralType) getDataType();
}
} }