下面列出了怎么用java.sql.SQLData的API类实例代码及写法,或者点击链接到github查看源代码。
@SuppressWarnings("unchecked")
protected <T> ContextualIndexedSetter<PreparedStatement, T> getIndexedSetter(Type propertyType, PropertyMapping<?, ?, JdbcColumnKey> arg, ContextFactoryBuilder contextFactoryBuilder) {
ContextualIndexedSetter<PreparedStatement, T> setter = null;
if (TypeHelper.isEnum(propertyType)) {
switch (arg.getColumnKey().getSqlType(arg.getColumnDefinition().properties())) {
case Types.NUMERIC:
case Types.BIGINT:
case Types.INTEGER:
case Types.DECIMAL:
case Types.DOUBLE:
case Types.FLOAT:
case Types.SMALLINT:
case Types.REAL:
case Types.TINYINT:
setter = (ContextualIndexedSetter<PreparedStatement, T>) new OrdinalEnumPreparedStatementIndexSetter();
break;
default:
setter = (ContextualIndexedSetter<PreparedStatement, T>) new StringEnumPreparedStatementIndexSetter();
}
}
if (setter == null) {
Factory setterFactory = this.factoryPerClass.get(TypeHelper.toClass(propertyType));
if (setterFactory != null) {
setter = setterFactory.<T>getIndexedSetter(arg.getColumnKey(), contextFactoryBuilder, arg.getColumnDefinition().properties());
}
}
if (setter == null && TypeHelper.isAssignable(SQLData.class, propertyType)) {
setter = (ContextualIndexedSetter<PreparedStatement, T>) new ObjectPreparedStatementIndexSetter();
}
return setter;
}