Java Code Examples for org.hibernate.query.criteria.LiteralHandlingMode

The following examples show how to use org.hibernate.query.criteria.LiteralHandlingMode. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: lams   Source File: LiteralExpression.java    License: GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings({ "unchecked" })
public String render(RenderingContext renderingContext) {

	LiteralHandlingMode literalHandlingMode = renderingContext.getCriteriaLiteralHandlingMode();

	switch ( literalHandlingMode ) {
		case AUTO:
			if ( ValueHandlerFactory.isNumeric( literal ) ) {
				return ValueHandlerFactory.determineAppropriateHandler( (Class) literal.getClass() ).render( literal );
			}
			else {
				return bindLiteral( renderingContext );
			}
		case BIND:
			return bindLiteral( renderingContext );
		case INLINE:
			Object literalValue = literal;
			if ( String.class.equals( literal.getClass() ) ) {
				literalValue = renderingContext.getDialect().inlineLiteral( (String) literal );
			}
			return ValueHandlerFactory.determineAppropriateHandler( (Class) literal.getClass() ).render( literalValue );
		default:
			throw new IllegalArgumentException( "Unexpected LiteralHandlingMode: " + literalHandlingMode );
	}
}
 
Example 2
@Override
	public LiteralHandlingMode getCriteriaLiteralHandlingMode() {
		return LiteralHandlingMode.INLINE;
//				return criteriaLiteralHandlingMode;
	}
 
Example 3
@Override
public LiteralHandlingMode getCriteriaLiteralHandlingMode() {
	return delegate.getCriteriaLiteralHandlingMode();
}
 
Example 4
Source Project: lams   Source File: SessionFactoryOptions.java    License: GNU General Public License v2.0 4 votes vote down vote up
default LiteralHandlingMode getCriteriaLiteralHandlingMode() {
	return LiteralHandlingMode.AUTO;
}
 
Example 5
@Override
public LiteralHandlingMode getCriteriaLiteralHandlingMode() {
	return this.criteriaLiteralHandlingMode;
}
 
Example 6
@Override
protected void additionalProperties(Properties properties) {
    properties.put(AvailableSettings.CRITERIA_LITERAL_HANDLING_MODE, LiteralHandlingMode.INLINE);
}
 
Example 7
@Override
protected void additionalProperties(Properties properties) {
    properties.put(AvailableSettings.CRITERIA_LITERAL_HANDLING_MODE, LiteralHandlingMode.BIND);
}
 
Example 8
Source Project: lams   Source File: RenderingContext.java    License: GNU General Public License v2.0 2 votes vote down vote up
/**
 * How literals are going to be handled.
 *
 * @return literal handling strategy
 */
default LiteralHandlingMode getCriteriaLiteralHandlingMode() {
	return LiteralHandlingMode.AUTO;
}