/** * Register the given javaType for the given table and column * * @param table * @param column * @param javaType */ public void register(String table, String column, Class<?> javaType) { register(table, column, javaTypeMapping.getType(javaType)); }
/** * Get the literal representation of the given constant * * @param o * @return */ public String asLiteral(Object o) { if (Null.class.isInstance(o)) { return "null"; } else { Type type = javaTypeMapping.getType(o.getClass()); if (type != null) { return templates.serialize(type.getLiteral(o), type.getSQLTypes()[0]); } else { throw new IllegalArgumentException("Unsupported literal type " + o.getClass().getName()); } } }
@SuppressWarnings({ "unchecked", "rawtypes" }) private <T> Type<T> getType(@Nullable Path<?> path, Class<T> clazz) { if (hasTableColumnTypes && path != null && !clazz.equals(Null.class) && path.getMetadata().getParent() instanceof RelationalPath) { String table = ((RelationalPath)path.getMetadata().getParent()).getTableName(); String column = ColumnMetadata.getName(path); Type<T> type = (Type)javaTypeMapping.getType(table, column); if (type != null) { return type; } } return javaTypeMapping.getType(clazz); }
Type<?> type = javaTypeMapping.getType(tableName, columnName); if (type != null) { return type.getReturnedClass();
/** * * @param type * @return */ public String getTypeNameForCast(Class<?> type) { Integer jdbcType = jdbcTypeMapping.get(type); if (jdbcType == null) { jdbcType = javaTypeMapping.getType(type).getSQLTypes()[0]; } return templates.getCastTypeNameForCode(jdbcType); }
/** * Get the SQL type name for the given java type * * @param type * @return */ public String getTypeName(Class<?> type) { Integer jdbcType = jdbcTypeMapping.get(type); if (jdbcType == null) { jdbcType = javaTypeMapping.getType(type).getSQLTypes()[0]; } return templates.getTypeNameForCode(jdbcType); }