code: private Object castLiteral(Object literal, String propertyName) {
  		try {
  			if (literal instanceof Collection) {
  				return castCollection(literal, propertyName);
  			}
  			if (literal instanceof Object[]) {
  				return castObjectArray(literal, propertyName);
  			}
  			Class<?> clazz = featureModel.getPropertyClass(featureModel.getEntityMetadata(), propertyName);
  			if (!clazz.equals(literal.getClass())) {
  				if (clazz.equals(Boolean.class)) {
  					return Boolean.valueOf(literal.toString());
  				} else if (clazz.equals(Date.class)) {
  					dateFormat.parse(literal.toString());
  				} else if (clazz.equals(Double.class)) {
  					return Double.valueOf(literal.toString());
  				} else if (clazz.equals(Float.class)) {
  					return Float.valueOf(literal.toString());
  				} else if (clazz.equals(Integer.class)) {
  					return Integer.valueOf(literal.toString());
  				} else if (clazz.equals(Long.class)) {
  					return Long.valueOf(literal.toString());
  				} else if (clazz.equals(Short.class)) {
  					return Short.valueOf(literal.toString());
  				} else if (clazz.equals(String.class)) {
  					return literal.toString();
  				}
  			}
  		} catch (Exception e) { // NOSONAR
  			log.error(e.getMessage(), e);
  		}
  		return literal;
  	}
docs: Literals from filters do not always have the right class (i.e. integer instead of long). This function can cast
  those objects.
  
  @param literal
  The literal object that needs casting to the correct class.
  @param propertyName
  The name of the property. Only by knowing what property we're talking about, can we derive it's class
  from the Hibernate metadata.
  @return Always returns a value!