本文整理了Java中javax.persistence.Converter.<init>()
方法的一些代码示例,展示了Converter.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Converter.<init>()
方法的具体详情如下:
包路径:javax.persistence.Converter
类名称:Converter
方法名:<init>
暂无
代码示例来源:origin: spring-projects/spring-data-jpa
@Converter(autoApply = true)
public static class ZoneIdConverter implements AttributeConverter<ZoneId, String> {
@Override
public String convertToDatabaseColumn(ZoneId zoneId) {
return ZoneIdToStringConverter.INSTANCE.convert(zoneId);
}
@Override
public ZoneId convertToEntityAttribute(String zoneId) {
return StringToZoneIdConverter.INSTANCE.convert(zoneId);
}
}
}
代码示例来源:origin: spring-projects/spring-data-jpa
@Converter(autoApply = true)
public static class LocalDateTimeConverter implements AttributeConverter<LocalDateTime, Date> {
@Override
public Date convertToDatabaseColumn(LocalDateTime date) {
return LocalDateTimeToDateConverter.INSTANCE.convert(date);
}
@Override
public LocalDateTime convertToEntityAttribute(Date date) {
return DateToLocalDateTimeConverter.INSTANCE.convert(date);
}
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Test candidate for {@link Converter}.
*
* @author Stephane Nicoll
*/
@Converter
public class SampleConverter {
}
代码示例来源:origin: hibernate/hibernate-orm
@Converter(autoApply = false)
public static class NotAutoAppliedConverter implements AttributeConverter<String,String> {
@Override
public String convertToDatabaseColumn(String attribute) {
throw new IllegalStateException( "AttributeConverter should not have been applied/called" );
}
@Override
public String convertToEntityAttribute(String dbData) {
throw new IllegalStateException( "AttributeConverter should not have been applied/called" );
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Converter( autoApply = false )
public static class ColorTypeConverter implements AttributeConverter<ColorType, String> {
@Override
public String convertToDatabaseColumn(ColorType attribute) {
return attribute == null ? null : attribute.toExternalForm();
}
@Override
public ColorType convertToEntityAttribute(String dbData) {
return ColorType.fromExternalForm( dbData );
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Converter(autoApply = true)
public static class ConvertibleEnumConverter implements AttributeConverter<ConvertibleEnum, String> {
@Override
public String convertToDatabaseColumn(ConvertibleEnum attribute) {
return attribute.convertToString();
}
@Override
public ConvertibleEnum convertToEntityAttribute(String dbData) {
return ConvertibleEnum.valueOf( dbData );
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Converter( autoApply = true )
public static class InstantConverter implements AttributeConverter<Instant, Timestamp> {
@Override
public Timestamp convertToDatabaseColumn(Instant attribute) {
return new Timestamp( attribute.toJavaMillis() );
}
@Override
public Instant convertToEntityAttribute(Timestamp dbData) {
return Instant.fromJavaMillis( dbData.getTime() );
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Converter( autoApply = true )
public static class MoneyConverter implements AttributeConverter<Money, BigDecimal> {
@Override
public BigDecimal convertToDatabaseColumn(Money attribute) {
return attribute == null ? null : new BigDecimal(attribute.toString());
}
@Override
public Money convertToEntityAttribute(BigDecimal dbData) {
return dbData == null ? null : new Money( dbData.toString() );
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Converter( autoApply = false )
public static class ColorTypeConverter implements AttributeConverter<ColorType, String> {
@Override
public String convertToDatabaseColumn(ColorType attribute) {
return attribute == null ? null : attribute.toExternalForm();
}
@Override
public ColorType convertToEntityAttribute(String dbData) {
return ColorType.fromExternalForm( dbData );
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Converter(autoApply = true)
public static class YearMonthAttributeConverter
implements AttributeConverter<YearMonth, Integer> {
@Override
public Integer convertToDatabaseColumn(YearMonth attribute) {
return (attribute.getYear() * 100) + attribute.getMonth().getValue();
}
@Override
public YearMonth convertToEntityAttribute(Integer dbData) {
return YearMonth.of(dbData / 100, dbData % 100);
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Converter( autoApply = true )
public static class ColorTypeConverter implements AttributeConverter<ColorType, String> {
@Override
public String convertToDatabaseColumn(ColorType attribute) {
return attribute == null ? null : attribute.toExternalForm();
}
@Override
public ColorType convertToEntityAttribute(String dbData) {
return ColorType.fromExternalForm( dbData );
}
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Converter( autoApply = true )
public static class IntegerToVarcharConverter implements AttributeConverter<Integer,String> {
@Override
public String convertToDatabaseColumn(Integer attribute) {
return attribute == null ? null : attribute.toString();
}
@Override
public Integer convertToEntityAttribute(String dbData) {
return dbData == null ? null : Integer.valueOf( dbData );
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Converter
public static class ConverterImpl implements AttributeConverter<String, Integer> {
@Override
public Integer convertToDatabaseColumn(String attribute) {
return attribute.length();
}
@Override
public String convertToEntityAttribute(Integer dbData) {
return "";
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Converter(autoApply = false)
public static class NotAutoAppliedConverter implements AttributeConverter<String,String> {
@Override
public String convertToDatabaseColumn(String attribute) {
throw new IllegalStateException( "AttributeConverter should not have been applied/called" );
}
@Override
public String convertToEntityAttribute(String dbData) {
throw new IllegalStateException( "AttributeConverter should not have been applied/called" );
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Converter
public static class ImmutableMutable2ConverterImpl implements AttributeConverter<MutableState2,String> {
@Override
public String convertToDatabaseColumn(MutableState2 attribute) {
immutableMutableToDatabaseCallCount++;
return attribute == null ? null : attribute.getState();
}
@Override
public MutableState2 convertToEntityAttribute(String dbData) {
immutableMutableToDomainCallCount++;
return new MutableState2( dbData );
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Converter
public static class MutableConverterImpl implements AttributeConverter<MutableState,String> {
@Override
public String convertToDatabaseColumn(MutableState attribute) {
mutableToDatabaseCallCount++;
return attribute == null ? null : attribute.getState();
}
@Override
public MutableState convertToEntityAttribute(String dbData) {
mutableToDomainCallCount++;
return new MutableState( dbData );
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Converter
public static class ImmutableConverterImpl implements AttributeConverter<ImmutableState,String> {
@Override
public String convertToDatabaseColumn(ImmutableState attribute) {
immutableToDatabaseCallCount++;
return attribute == null ? null : attribute.getState();
}
@Override
public ImmutableState convertToEntityAttribute(String dbData) {
immutableToDomainCallCount++;
return new ImmutableState( dbData );
}
}
代码示例来源:origin: hibernate/hibernate-orm
/**
* @author Vlad Mihalcea
*/
@Converter( autoApply = true )
class IntegerToVarcharConverter implements AttributeConverter<Integer,String> {
@Override
public String convertToDatabaseColumn(Integer attribute) {
return attribute == null ? null : attribute.toString();
}
@Override
public Integer convertToEntityAttribute(String dbData) {
return dbData == null ? null : Integer.valueOf( dbData );
}
}
代码示例来源:origin: hibernate/hibernate-orm
/**
* @author Steve Ebersole
*/
@Converter(autoApply = true)
public class ColorTypeConverter implements AttributeConverter<ColorType, String> {
@Override
public String convertToDatabaseColumn(ColorType attribute) {
return attribute == null ? null : attribute.toExternalForm();
}
@Override
public ColorType convertToEntityAttribute(String dbData) {
return dbData == null ? null : ColorType.fromExternalForm( dbData );
}
}
代码示例来源:origin: hibernate/hibernate-orm
/**
*
* @author soldierkam
*/
@Converter(autoApply=true)
public class ExifConverter implements AttributeConverter<String, Exif> {
@Override
public Exif convertToDatabaseColumn(String attribute) {
return new Exif( Collections.singletonMap( "fakeAttr", attribute ) );
}
@Override
public String convertToEntityAttribute(Exif dbData) {
return dbData.getAttributes().get( "fakeAttr" );
}
}
内容来源于网络,如有侵权,请联系作者删除!