HHH-16990 Make marshalling adapters null-safe

This commit is contained in:
marko-bekhta 2023-07-25 10:15:06 +02:00 committed by Christian Beikov
parent 93f1ed6e76
commit 7edb7984a8
18 changed files with 36 additions and 36 deletions

View File

@ -15,10 +15,10 @@ import jakarta.persistence.AccessType;
*/
public class AccessTypeMarshalling {
public static AccessType fromXml(String name) {
return AccessType.valueOf( name );
return name == null ? null : AccessType.valueOf( name );
}
public static String toXml(AccessType accessType) {
return accessType.name();
return accessType == null ? null : accessType.name();
}
}

View File

@ -16,10 +16,10 @@ import org.hibernate.cache.spi.access.AccessType;
*/
public class CacheAccessTypeMarshalling {
public static AccessType fromXml(String name) {
return AccessType.fromExternalName( name );
return name == null ? null : AccessType.fromExternalName( name );
}
public static String toXml(AccessType accessType) {
return accessType.name();
return accessType == null ? null : accessType.name();
}
}

View File

@ -26,6 +26,6 @@ public class CacheModeMarshalling {
}
public static String toXml(CacheMode cacheMode) {
return cacheMode.name().toLowerCase( Locale.ENGLISH );
return cacheMode == null ? null : cacheMode.name().toLowerCase( Locale.ENGLISH );
}
}

View File

@ -15,10 +15,10 @@ import org.hibernate.metamodel.CollectionClassification;
*/
public class CollectionClassificationMarshalling {
public static CollectionClassification fromXml(String name) {
return CollectionClassification.interpretSetting( name.replace( '-', '_' ) );
return name == null ? null : CollectionClassification.interpretSetting( name.replace( '-', '_' ) );
}
public static String toXml(CollectionClassification classification) {
return classification.name().replace( '_', '-' );
return classification == null ? null : classification.name().replace( '_', '-' );
}
}

View File

@ -15,10 +15,10 @@ import jakarta.persistence.ConstraintMode;
*/
public class ConstraintModeMarshalling {
public static ConstraintMode fromXml(String name) {
return ConstraintMode.valueOf( name );
return name == null ? null : ConstraintMode.valueOf( name );
}
public static String toXml(ConstraintMode accessType) {
return accessType.name();
public static String toXml(ConstraintMode constraintMode) {
return constraintMode == null ? null : constraintMode.name();
}
}

View File

@ -15,10 +15,10 @@ import jakarta.persistence.DiscriminatorType;
*/
public class DiscriminatorTypeMarshalling {
public static DiscriminatorType fromXml(String name) {
return DiscriminatorType.valueOf( name );
return name == null ? null : DiscriminatorType.valueOf( name );
}
public static String toXml(DiscriminatorType discriminatorType) {
return discriminatorType.name();
return discriminatorType == null ? null : discriminatorType.name();
}
}

View File

@ -15,10 +15,10 @@ import jakarta.persistence.EnumType;
*/
public class EnumTypeMarshalling {
public static EnumType fromXml(String name) {
return EnumType.valueOf( name );
return name == null ? null : EnumType.valueOf( name );
}
public static String toXml(EnumType enumType) {
return enumType.name();
return enumType == null ? null : enumType.name();
}
}

View File

@ -15,10 +15,10 @@ import jakarta.persistence.FetchType;
*/
public class FetchTypeMarshalling {
public static FetchType fromXml(String name) {
return FetchType.valueOf( name );
return name == null ? null : FetchType.valueOf( name );
}
public static String toXml(FetchType fetchType) {
return fetchType.name();
return fetchType == null ? null : fetchType.name();
}
}

View File

@ -17,7 +17,7 @@ import org.hibernate.tuple.GenerationTiming;
*/
public class GenerationTimingMarshalling {
public static GenerationTiming fromXml(String name) {
return GenerationTiming.parseFromName( name );
return name == null ? null : GenerationTiming.parseFromName( name );
}
public static String toXml(GenerationTiming generationTiming) {

View File

@ -15,10 +15,10 @@ import jakarta.persistence.GenerationType;
*/
public class GenerationTypeMarshalling {
public static GenerationType fromXml(String name) {
return GenerationType.valueOf( name );
return name == null ? null : GenerationType.valueOf( name );
}
public static String toXml(GenerationType accessType) {
return accessType.name();
public static String toXml(GenerationType generationType) {
return generationType == null ? null : generationType.name();
}
}

View File

@ -15,10 +15,10 @@ import jakarta.persistence.InheritanceType;
*/
public class InheritanceTypeMarshalling {
public static InheritanceType fromXml(String name) {
return InheritanceType.valueOf( name );
return name == null ? null : InheritanceType.valueOf( name );
}
public static String toXml(InheritanceType accessType) {
return accessType.name();
public static String toXml(InheritanceType inheritanceType) {
return inheritanceType == null ? null : inheritanceType.name();
}
}

View File

@ -15,10 +15,10 @@ import jakarta.persistence.LockModeType;
*/
public class LockModeTypeMarshalling {
public static LockModeType fromXml(String name) {
return LockModeType.valueOf( name );
return name == null ? null : LockModeType.valueOf( name );
}
public static String toXml(LockModeType lockModeType) {
return lockModeType.name();
return lockModeType == null ? null : lockModeType.name();
}
}

View File

@ -13,10 +13,10 @@ import org.hibernate.annotations.OnDeleteAction;
*/
public class OnDeleteActionMarshalling {
public static OnDeleteAction fromXml(String name) {
return OnDeleteAction.fromExternalForm( name );
return name == null ? null : OnDeleteAction.fromExternalForm( name );
}
public static String toXml(OnDeleteAction accessType) {
return accessType.getAlternativeName();
return accessType == null ? null : accessType.getAlternativeName();
}
}

View File

@ -17,7 +17,7 @@ import org.hibernate.engine.OptimisticLockStyle;
*/
public class OptimisticLockStyleMarshalling {
public static OptimisticLockStyle fromXml(String name) {
return OptimisticLockStyle.valueOf( name == null ? null : name.toUpperCase( Locale.ENGLISH ) );
return name == null ? null : OptimisticLockStyle.valueOf( name.toUpperCase( Locale.ENGLISH ) );
}
public static String toXml(OptimisticLockStyle lockMode) {

View File

@ -15,10 +15,10 @@ import jakarta.persistence.ParameterMode;
*/
public class ParameterModeMarshalling {
public static ParameterMode fromXml(String name) {
return ParameterMode.valueOf( name );
return name == null ? null : ParameterMode.valueOf( name );
}
public static String toXml(ParameterMode parameterMode) {
return parameterMode.name();
return parameterMode == null ? null : parameterMode.name();
}
}

View File

@ -13,10 +13,10 @@ import org.hibernate.annotations.PolymorphismType;
*/
public class PolymorphismTypeMarshalling {
public static PolymorphismType fromXml(String value) {
return PolymorphismType.fromExternalValue( value );
return value == null ? null : PolymorphismType.fromExternalValue( value );
}
public static String toXml(PolymorphismType value) {
return value.getExternalForm();
return value == null ? null : value.getExternalForm();
}
}

View File

@ -15,10 +15,10 @@ import org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle;
*/
public class ResultCheckStyleMarshalling {
public static ExecuteUpdateResultCheckStyle fromXml(String name) {
return ExecuteUpdateResultCheckStyle.fromExternalName( name );
return name == null ? null : ExecuteUpdateResultCheckStyle.fromExternalName( name );
}
public static String toXml(ExecuteUpdateResultCheckStyle style) {
return style.externalName();
return style == null ? null : style.externalName();
}
}

View File

@ -15,10 +15,10 @@ import jakarta.persistence.TemporalType;
*/
public class TemporalTypeMarshalling {
public static TemporalType fromXml(String name) {
return TemporalType.valueOf( name );
return name == null ? null : TemporalType.valueOf( name );
}
public static String toXml(TemporalType temporalType) {
return temporalType.name();
return temporalType == null ? null : temporalType.name();
}
}