org.hibernate.query.criteria.LiteralHandlingMode Java Examples

The following examples show how to use org.hibernate.query.criteria.LiteralHandlingMode. 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 File: LiteralExpression.java    From lams with 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
Source File: CriteriaQueryRenderingContext.java    From hibernate-reactive with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
	public LiteralHandlingMode getCriteriaLiteralHandlingMode() {
		return LiteralHandlingMode.INLINE;
//				return criteriaLiteralHandlingMode;
	}
 
Example #3
Source File: AbstractDelegatingSessionFactoryOptions.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public LiteralHandlingMode getCriteriaLiteralHandlingMode() {
	return delegate.getCriteriaLiteralHandlingMode();
}
 
Example #4
Source File: SessionFactoryOptions.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
default LiteralHandlingMode getCriteriaLiteralHandlingMode() {
	return LiteralHandlingMode.AUTO;
}
 
Example #5
Source File: SessionFactoryOptionsBuilder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
public LiteralHandlingMode getCriteriaLiteralHandlingMode() {
	return this.criteriaLiteralHandlingMode;
}
 
Example #6
Source File: InlineCriteriaLiteralTest.java    From high-performance-java-persistence with Apache License 2.0 4 votes vote down vote up
@Override
protected void additionalProperties(Properties properties) {
    properties.put(AvailableSettings.CRITERIA_LITERAL_HANDLING_MODE, LiteralHandlingMode.INLINE);
}
 
Example #7
Source File: BindCriteriaLiteralTest.java    From high-performance-java-persistence with Apache License 2.0 4 votes vote down vote up
@Override
protected void additionalProperties(Properties properties) {
    properties.put(AvailableSettings.CRITERIA_LITERAL_HANDLING_MODE, LiteralHandlingMode.BIND);
}
 
Example #8
Source File: RenderingContext.java    From lams with 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;
}