public class DerbyConcatFunction extends Object implements SQLFunction
Constructor and Description |
---|
DerbyConcatFunction() |
Modifier and Type | Method and Description |
---|---|
Type |
getReturnType(Type argumentType,
Mapping mapping)
The return type of the function.
|
boolean |
hasArguments()
Does this function have any arguments?
|
boolean |
hasParenthesesIfNoArguments()
If there are no arguments, are parentheses required?
|
String |
render(Type argumentType,
List args,
SessionFactoryImplementor factory)
Render the function call as SQL fragment.
|
public boolean hasArguments()
hasArguments
in interface SQLFunction
public boolean hasParenthesesIfNoArguments()
hasParenthesesIfNoArguments
in interface SQLFunction
public Type getReturnType(Type argumentType, Mapping mapping) throws QueryException
SQLFunction.render(org.hibernate.type.Type, java.util.List, org.hibernate.engine.spi.SessionFactoryImplementor)
Here we always return StandardBasicTypes.STRING
.getReturnType
in interface SQLFunction
argumentType
- The type of the first argumentmapping
- The mapping source.QueryException
- Indicates an issue resolving the return type.public String render(Type argumentType, List args, SessionFactoryImplementor factory) throws QueryException
SQLFunction.getReturnType(org.hibernate.type.Type, org.hibernate.engine.spi.Mapping)
Here's the meat.. The whole reason we have a separate impl for this for Derby is to re-define
this method. The logic here says that if not all the incoming args are dynamic parameters
(i.e. ?) then we simply use the Derby concat operator (||) on the unchanged
arg elements. However, if all the args are dynamic parameters, then we need to wrap the individual
arg elements in cast function calls, use the concatenation operator on the cast
returns, and then wrap that whole thing in a call to the Derby varchar function.render
in interface SQLFunction
argumentType
- The type of the first argumentargs
- The function argumentsfactory
- The SessionFactoryQueryException
- Indicates a problem rendering the
function call.Copyright © 2012 JBoss by Red Hat. All Rights Reserved.