HHH-3510 : HQL SQLFunction replacement not occuring when HQL text has no parenthesis
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@15242 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
cdb1c9dda5
commit
d4f929aab3
|
@ -38,6 +38,7 @@ import org.hibernate.type.Type;
|
|||
import org.hibernate.util.StringHelper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Represents an identifier all by itself, which may be a function name,
|
||||
|
@ -128,6 +129,14 @@ public class IdentNode extends FromReferenceNode implements SelectExpression {
|
|||
// resolve this...
|
||||
return;
|
||||
}
|
||||
else if ( result == UNKNOWN ) {
|
||||
final SQLFunction sqlFunction = getSessionFactoryHelper().findSQLFunction( getText() );
|
||||
if ( sqlFunction != null ) {
|
||||
setText( sqlFunction.render( Collections.EMPTY_LIST, getSessionFactoryHelper().getFactory() ) );
|
||||
setDataType( sqlFunction.getReturnType( null, getSessionFactoryHelper().getFactory() ) );
|
||||
setResolved();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if we are still not resolved, we might represent a constant.
|
||||
|
@ -283,11 +292,14 @@ public class IdentNode extends FromReferenceNode implements SelectExpression {
|
|||
|
||||
public Type getDataType() {
|
||||
Type type = super.getDataType();
|
||||
if (type != null) return type;
|
||||
if ( type != null ) {
|
||||
return type;
|
||||
}
|
||||
FromElement fe = getFromElement();
|
||||
if (fe != null) return fe.getDataType();
|
||||
SQLFunction sf = getWalker().getSessionFactoryHelper().findSQLFunction(getText());
|
||||
return sf == null ? null : sf.getReturnType(null, null);
|
||||
if ( fe != null ) {
|
||||
return fe.getDataType();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setScalarColumnText(int i) throws SemanticException {
|
||||
|
@ -322,7 +334,7 @@ public class IdentNode extends FromReferenceNode implements SelectExpression {
|
|||
buf.append( "}" );
|
||||
}
|
||||
else {
|
||||
buf.append("{originalText=" + getOriginalText()).append("}");
|
||||
buf.append( "{originalText=" ).append( getOriginalText() ).append( "}" );
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue