本文整理了Java中javax.persistence.Converter
类的一些代码示例,展示了Converter
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Converter
类的具体详情如下:
包路径:javax.persistence.Converter
类名称:Converter
暂无
代码示例来源: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: hibernate/hibernate-orm
private AutoApplicableConverterDescriptor resolveAutoApplicableDescriptor(
Class<? extends AttributeConverter> converterClass,
Boolean forceAutoApply) {
final boolean autoApply;
if ( forceAutoApply != null ) {
// if the caller explicitly specified whether to auto-apply, honor that
autoApply = forceAutoApply;
}
else {
// otherwise, look at the converter's @Converter annotation
final Converter annotation = converterClass.getAnnotation( Converter.class );
autoApply = annotation != null && annotation.autoApply();
}
return autoApply
? new AutoApplicableConverterDescriptorStandardImpl( this )
: AutoApplicableConverterDescriptorBypassedImpl.INSTANCE;
}
代码示例来源: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: hibernate/hibernate-orm
/**
* Build an AttributeConverterDefinition from an AttributeConverter instance. The
* converter is searched for a {@link Converter} annotation to determine whether it should
* be treated as auto-apply. If the annotation is present, {@link Converter#autoApply()} is
* used to make that determination. If the annotation is not present, {@code false} is assumed.
*
* @param attributeConverter The AttributeConverter instance
*
* @return The constructed definition
*/
public static AttributeConverterDefinition from(AttributeConverter attributeConverter) {
boolean autoApply = false;
Converter converterAnnotation = attributeConverter.getClass().getAnnotation( Converter.class );
if ( converterAnnotation != null ) {
autoApply = converterAnnotation.autoApply();
}
return new AttributeConverterDefinition( attributeConverter, autoApply );
}
代码示例来源:origin: spring-projects/spring-data-jpa
@Converter(autoApply = true)
public static class InstantConverter implements AttributeConverter<Instant, Date> {
@Override
public Date convertToDatabaseColumn(Instant instant) {
return InstantToDateConverter.INSTANCE.convert(instant);
}
@Override
public Instant convertToEntityAttribute(Date date) {
return DateToInstantConverter.INSTANCE.convert(date);
}
}
代码示例来源:origin: spring-projects/spring-data-jpa
@Converter(autoApply = true)
public static class LocalDateConverter implements AttributeConverter<LocalDate, Date> {
@Override
public Date convertToDatabaseColumn(LocalDate date) {
return LocalDateToDateConverter.INSTANCE.convert(date);
}
@Override
public LocalDate convertToEntityAttribute(Date date) {
return DateToLocalDateConverter.INSTANCE.convert(date);
}
}
代码示例来源:origin: spring-projects/spring-data-jpa
@Converter(autoApply = true)
public static class LocalTimeConverter implements AttributeConverter<LocalTime, Date> {
@Override
public Date convertToDatabaseColumn(LocalTime time) {
return LocalTimeToDateConverter.INSTANCE.convert(time);
}
@Override
public LocalTime convertToEntityAttribute(Date date) {
return DateToLocalTimeConverter.INSTANCE.convert(date);
}
}
代码示例来源:origin: spring-projects/spring-data-jpa
@Converter(autoApply = true)
public static class InstantConverter implements AttributeConverter<Instant, Date> {
@Nullable
@Override
public Date convertToDatabaseColumn(Instant instant) {
return instant == null ? null : InstantToDateConverter.INSTANCE.convert(instant);
}
@Nullable
@Override
public Instant convertToEntityAttribute(Date date) {
return date == null ? null : DateToInstantConverter.INSTANCE.convert(date);
}
}
代码示例来源:origin: spring-projects/spring-data-jpa
@Converter(autoApply = true)
public static class LocalDateConverter implements AttributeConverter<LocalDate, Date> {
@Nullable
@Override
public Date convertToDatabaseColumn(LocalDate date) {
return date == null ? null : LocalDateToDateConverter.INSTANCE.convert(date);
}
@Nullable
@Override
public LocalDate convertToEntityAttribute(Date date) {
return date == null ? null : DateToLocalDateConverter.INSTANCE.convert(date);
}
}
代码示例来源:origin: spring-projects/spring-data-jpa
@Converter(autoApply = true)
public static class LocalTimeConverter implements AttributeConverter<LocalTime, Date> {
@Nullable
@Override
public Date convertToDatabaseColumn(LocalTime time) {
return time == null ? null : LocalTimeToDateConverter.INSTANCE.convert(time);
}
@Nullable
@Override
public LocalTime convertToEntityAttribute(Date date) {
return date == null ? null : DateToLocalTimeConverter.INSTANCE.convert(date);
}
}
代码示例来源:origin: spring-projects/spring-data-jpa
@Converter(autoApply = true)
public static class LocalDateTimeConverter implements AttributeConverter<LocalDateTime, Date> {
@Nullable
@Override
public Date convertToDatabaseColumn(LocalDateTime date) {
return date == null ? null : LocalDateTimeToDateConverter.INSTANCE.convert(date);
}
@Nullable
@Override
public LocalDateTime convertToEntityAttribute(Date date) {
return date == null ? null : DateToLocalDateTimeConverter.INSTANCE.convert(date);
}
}
代码示例来源:origin: spring-projects/spring-data-jpa
@Converter(autoApply = true)
public static class ZoneIdConverter implements AttributeConverter<ZoneId, String> {
@Nullable
@Override
public String convertToDatabaseColumn(ZoneId zoneId) {
return zoneId == null ? null : ZoneIdToStringConverter.INSTANCE.convert(zoneId);
}
@Nullable
@Override
public ZoneId convertToEntityAttribute(String zoneId) {
return zoneId == null ? null : StringToZoneIdConverter.INSTANCE.convert(zoneId);
}
}
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Test candidate for {@link Converter}.
*
* @author Stephane Nicoll
*/
@Converter
public class SampleConverter {
}
代码示例来源:origin: mitreid-connect/OpenID-Connect-Java-Spring-Server
@Converter
public class JWEAlgorithmStringConverter implements AttributeConverter<JWEAlgorithm, String> {
@Override
public String convertToDatabaseColumn(JWEAlgorithm attribute) {
if (attribute != null) {
return attribute.getName();
} else {
return null;
}
}
/* (non-Javadoc)
* @see javax.persistence.AttributeConverter#convertToEntityAttribute(java.lang.Object)
*/
@Override
public JWEAlgorithm convertToEntityAttribute(String dbData) {
if (dbData != null) {
return JWEAlgorithm.parse(dbData);
} else {
return null;
}
}
}
代码示例来源:origin: mitreid-connect/OpenID-Connect-Java-Spring-Server
@Converter
public class JWEEncryptionMethodStringConverter implements AttributeConverter<EncryptionMethod, String> {
@Override
public String convertToDatabaseColumn(EncryptionMethod attribute) {
if (attribute != null) {
return attribute.getName();
} else {
return null;
}
}
/* (non-Javadoc)
* @see javax.persistence.AttributeConverter#convertToEntityAttribute(java.lang.Object)
*/
@Override
public EncryptionMethod convertToEntityAttribute(String dbData) {
if (dbData != null) {
return EncryptionMethod.parse(dbData);
} else {
return null;
}
}
}
代码示例来源:origin: mitreid-connect/OpenID-Connect-Java-Spring-Server
@Converter
public class JWSAlgorithmStringConverter implements AttributeConverter<JWSAlgorithm, String> {
@Override
public String convertToDatabaseColumn(JWSAlgorithm attribute) {
if (attribute != null) {
return attribute.getName();
} else {
return null;
}
}
/* (non-Javadoc)
* @see javax.persistence.AttributeConverter#convertToEntityAttribute(java.lang.Object)
*/
@Override
public JWSAlgorithm convertToEntityAttribute(String dbData) {
if (dbData != null) {
return JWSAlgorithm.parse(dbData);
} else {
return null;
}
}
}
代码示例来源:origin: mitreid-connect/OpenID-Connect-Java-Spring-Server
/**
* @author jricher
*
*/
@Converter
public class SimpleGrantedAuthorityStringConverter implements AttributeConverter<SimpleGrantedAuthority, String> {
@Override
public String convertToDatabaseColumn(SimpleGrantedAuthority attribute) {
if (attribute != null) {
return attribute.getAuthority();
} else {
return null;
}
}
@Override
public SimpleGrantedAuthority convertToEntityAttribute(String dbData) {
if (dbData != null) {
return new SimpleGrantedAuthority(dbData);
} else {
return null;
}
}
}
代码示例来源:origin: mitreid-connect/OpenID-Connect-Java-Spring-Server
@Converter
public class JsonElementStringConverter implements AttributeConverter<JsonElement, String> {
代码示例来源:origin: mitreid-connect/OpenID-Connect-Java-Spring-Server
/**
* @author jricher
*
*/
@Converter
public class PKCEAlgorithmStringConverter implements AttributeConverter<PKCEAlgorithm, String> {
@Override
public String convertToDatabaseColumn(PKCEAlgorithm attribute) {
if (attribute != null) {
return attribute.getName();
} else {
return null;
}
}
/* (non-Javadoc)
* @see javax.persistence.AttributeConverter#convertToEntityAttribute(java.lang.Object)
*/
@Override
public PKCEAlgorithm convertToEntityAttribute(String dbData) {
if (dbData != null) {
return PKCEAlgorithm.parse(dbData);
} else {
return null;
}
}
}
代码示例来源:origin: mitreid-connect/OpenID-Connect-Java-Spring-Server
@Converter
public class JsonObjectStringConverter implements AttributeConverter<JsonObject, String> {
内容来源于网络,如有侵权,请联系作者删除!