本文整理汇总了Java中javax.persistence.AttributeConverter.convertToDatabaseColumn方法的典型用法代码示例。如果您正苦于以下问题:Java AttributeConverter.convertToDatabaseColumn方法的具体用法?Java AttributeConverter.convertToDatabaseColumn怎么用?Java AttributeConverter.convertToDatabaseColumn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.persistence.AttributeConverter
的用法示例。
在下文中一共展示了AttributeConverter.convertToDatabaseColumn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setExpectedType
import javax.persistence.AttributeConverter; //导入方法依赖的package包/类
@Override
public void setExpectedType(Type expectedType) {
if ( this.expectedType != null ) {
return;
}
if ( AttributeConverterTypeAdapter.class.isInstance( expectedType ) ) {
final AttributeConverterTypeAdapter adapterType = (AttributeConverterTypeAdapter) expectedType;
if ( getDataType().getReturnedClass().equals( adapterType.getModelType() ) ) {
// apply the converter
final AttributeConverter converter = ( (AttributeConverterTypeAdapter) expectedType ).getAttributeConverter();
final Object converted = converter.convertToDatabaseColumn( getLiteralValue() );
if ( isCharacterData( adapterType.sqlType() ) ) {
setText( "'" + converted.toString() + "'" );
}
else {
setText( converted.toString() );
}
}
this.expectedType = expectedType;
}
}
示例2: append
import javax.persistence.AttributeConverter; //导入方法依赖的package包/类
Where<T> append(String type, String clause, Object... params) {
// check clause:
Mapper<T> mapper = this.criteria.mapper;
CompiledClause cc = CompiledClause.compile(mapper, clause);
if (cc.converters.length != params.length) {
throw new IllegalArgumentException("Arguments not match the placeholder.");
}
// convert params:
int n = 0;
for (AttributeConverter<Object, Object> converter : cc.converters) {
if (converter != null) {
params[n] = converter.convertToDatabaseColumn(params[n]);
}
n++;
}
// add:
if (type != null) {
this.criteria.where.add(type);
}
this.criteria.where.add(cc.clause);
for (Object param : params) {
this.criteria.whereParams.add(param);
}
return this;
}