From a9ba811baf2241ac1fba697e9be82a4ef7ae4233 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Wed, 12 May 2010 19:48:43 +0000 Subject: [PATCH] HHH-5138 - Redesign types + introduce TypeRegistry & TypeResolver git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@19483 1b8cb986-b30d-0410-93ca-fae66ebed9b2 --- .../java/SerializableTypeDescriptor.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/hibernate/type/descriptor/java/SerializableTypeDescriptor.java b/core/src/main/java/org/hibernate/type/descriptor/java/SerializableTypeDescriptor.java index 377b04c588..81e87d6aea 100644 --- a/core/src/main/java/org/hibernate/type/descriptor/java/SerializableTypeDescriptor.java +++ b/core/src/main/java/org/hibernate/type/descriptor/java/SerializableTypeDescriptor.java @@ -37,18 +37,33 @@ import org.hibernate.util.SerializationHelper; * @author Steve Ebersole */ public class SerializableTypeDescriptor extends AbstractTypeDescriptor { + // unfortunately the param types cannot be the same so use something other than 'T' here to make that obvious public static class SerializableMutabilityPlan extends MutableMutabilityPlan { - public static final SerializableMutabilityPlan INSTANCE = new SerializableMutabilityPlan(); + private final Class type; + + public static final SerializableMutabilityPlan INSTANCE + = new SerializableMutabilityPlan( Serializable.class ); + + public SerializableMutabilityPlan(Class type) { + this.type = type; + } + @SuppressWarnings({ "unchecked" }) public S deepCopyNotNull(S value) { return (S) SerializationHelper.clone( value ); } + } @SuppressWarnings({ "unchecked" }) public SerializableTypeDescriptor(Class type) { - super( type, SerializableMutabilityPlan.INSTANCE ); + super( + type, + Serializable.class.equals( type ) + ? (MutabilityPlan) SerializableMutabilityPlan.INSTANCE + : new SerializableMutabilityPlan( type ) + ); } public String toString(T value) {