本文整理匯總了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;
}