01: //$Id: MutableType.java 6883 2005-05-24 16:22:15Z oneovthafew $
02: package org.hibernate.type;
03:
04: import java.util.Map;
05:
06: import org.hibernate.EntityMode;
07: import org.hibernate.HibernateException;
08: import org.hibernate.engine.SessionFactoryImplementor;
09: import org.hibernate.engine.SessionImplementor;
10:
11: /**
12: * Superclass for mutable nullable types
13: * @author Gavin King
14: */
15: public abstract class MutableType extends NullableType {
16:
17: public final boolean isMutable() {
18: return true;
19: }
20:
21: protected abstract Object deepCopyNotNull(Object value)
22: throws HibernateException;
23:
24: public final Object deepCopy(Object value, EntityMode entityMode,
25: SessionFactoryImplementor factory)
26: throws HibernateException {
27: return (value == null) ? null : deepCopyNotNull(value);
28: }
29:
30: public Object replace(Object original, Object target,
31: SessionImplementor session, Object owner, Map copyCache)
32: throws HibernateException {
33: if (isEqual(original, target, session.getEntityMode()))
34: return original;
35: return deepCopy(original, session.getEntityMode(), session
36: .getFactory());
37: }
38:
39: }
|