Buggy code:
public < X > GreaterThan ( Expression < X > x , Object y ) { } @ Override public PredicateImpl negate ( ) { } @ Override Expression toKernelExpression ( ExpressionFactory factory , MetamodelImpl model , CriteriaQueryImpl < ? > q ) { } @ Override public StringBuilder asValue ( AliasContext q ) { } } public static class GreaterThanEqual extends Expressions . BinaryLogicalExpression { public < X , Y > GreaterThanEqual ( Expression < X > x , Expression < Y > y ) { } public < X > GreaterThanEqual ( Expression < X > x , Object y ) { } @ Override public PredicateImpl negate ( ) { } @ Override Expression toKernelExpression ( ExpressionFactory factory , MetamodelImpl model , CriteriaQueryImpl < ? > q ) { } @ Override public StringBuilder asValue ( AliasContext q ) { } } public static class LessThan extends Expressions . BinaryLogicalExpression { public < X , Y > LessThan ( Expression < X > x , Expression < Y > y ) { } public < X > LessThan ( Expression < X > x , Object y ) { } @ Override public PredicateImpl negate ( ) { } @ Override Expression toKernelExpression ( ExpressionFactory factory , MetamodelImpl model , CriteriaQueryImpl < ? > q ) { } @ Override public StringBuilder asValue ( AliasContext q ) { } } public static class LessThanEqual extends Expressions . BinaryLogicalExpression { public < X , Y > LessThanEqual ( Expression < X > x , Expression < Y > y ) { } public < X > LessThanEqual ( Expression < X > x , Object y ) { } @ Override public PredicateImpl negate ( ) { } @ Override Expression toKernelExpression ( ExpressionFactory factory , MetamodelImpl model , CriteriaQueryImpl < ? > q ) { } @ Override public StringBuilder asValue ( AliasContext q ) { } } public static class Between < Y extends Comparable < Y > > extends PredicateImpl . And { private final ExpressionImpl < ? extends Y > e ; private final ExpressionImpl < ? extends Y > v1 ; private final ExpressionImpl < ? extends Y > v2 ; public Between ( Expression < ? extends Y > v , Expression < ? extends Y > x , Expression < ? extends Y > y ) { } public Between ( Expression < ? extends Y > v , Y x , Y y ) { } @ Override public StringBuilder asValue ( AliasContext q ) { } } public static class Constant < X > extends ExpressionImpl < X > { public final Object arg ; public Constant ( Class < X > t , X x ) { } public Constant ( X x ) { } @ Override public Value toValue ( ExpressionFactory factory , MetamodelImpl model , CriteriaQueryImpl < ? > q ) { Object value = arg ; Class < ? > literalClass = Expressions . Constant . getJavaType ( ) ; if ( ( arg ) instanceof ParameterExpressionImpl ) { return ( ( ParameterExpressionImpl ) ( arg ) ) . toValue ( factory , model , q ) ; } int literalType = Literal . TYPE_UNKNOWN ; if ( Number . class . isAssignableFrom ( literalClass ) ) { literalType = Literal . TYPE_NUMBER ; } else if ( Boolean . class . isAssignableFrom ( literalClass ) ) { literalType = Literal . TYPE_BOOLEAN ; } else if ( String . class . isAssignableFrom ( literalClass ) ) { literalType = Literal . TYPE_STRING ; } else if ( Enum . class . isAssignableFrom ( literalClass ) ) { literalType = Literal . TYPE_ENUM ; } else if ( Class . class . isAssignableFrom ( literalClass ) ) { literalType = Literal . TYPE_CLASS ; Literal lit = factory . newTypeLiteral ( value , TYPE_CLASS ) ; ClassMetaData can = ( ( Types . Entity < X > ) ( q . getRoot ( ) . getModel ( ) ) ) . meta ; Class < ? > candidate = can . getDescribedType ( ) ; if ( candidate . isAssignableFrom ( ( ( Class ) ( value ) ) ) ) { <START_BUG> lit . setMetaData ( model . repos . getMetaData ( ( ( Class < ? > ) ( value ) ) , null , true ) ) ; <END_BUG> } else { lit . setMetaData ( can ) ; } return lit ; } else if ( Collection . class . isAssignableFrom ( literalClass ) ) { literalType = Literal . TYPE_COLLECTION ; } return factory . newLiteral ( value , literalType ) ; } public void acceptVisit ( CriteriaExpressionVisitor visitor ) { } public StringBuilder asValue ( AliasContext q ) { } } public static class IsEmpty extends PredicateImpl { final ExpressionImpl < ? > collection ; public IsEmpty ( Expression < ? > collection ) { } @ Override public PredicateImpl negate ( ) { } @ Override Value toValue ( ExpressionFactory factory , MetamodelImpl model , CriteriaQueryImpl < ? > q ) { return Expressions . toValue ( collection , factory , model , q ) ; } @ Override Expression toKernelExpression ( ExpressionFactory factory , MetamodelImpl model , CriteriaQueryImpl < ? > q ) { } public void acceptVisit ( CriteriaExpressionVisitor visitor ) { } @ Override public StringBuilder asValue ( AliasContext q ) { } } public static class IsNotEmpty extends PredicateImpl { final ExpressionImpl < ? > collection ; public IsNotEmpty ( Expression < ? > collection ) { } @ Override public PredicateImpl negate ( ) { } @ Override Value toValue ( ExpressionFactory factory , MetamodelImpl model , CriteriaQueryImpl < ? > q ) { return Expressions . toValue ( collection , factory , model , q ) ;

Fix:
lit . setMetaData ( model . getRepository ( ) . getMetaData ( ( ( Class < ? > ) ( value ) ) , null , true ) ) ;