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