diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/DiscriminatorType.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/DiscriminatorType.java index d346708936..2bb0367175 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/DiscriminatorType.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/DiscriminatorType.java @@ -37,18 +37,22 @@ public class DiscriminatorType extends AbstractType { this.persister = persister; } + @Override public Class getReturnedClass() { return Class.class; } + @Override public String getName() { return getClass().getName(); } + @Override public boolean isMutable() { return false; } + @Override public Object nullSafeGet( ResultSet rs, String[] names, @@ -57,6 +61,7 @@ public class DiscriminatorType extends AbstractType { return nullSafeGet( rs, names[0], session, owner ); } + @Override public Object nullSafeGet( ResultSet rs, String name, @@ -71,6 +76,7 @@ public class DiscriminatorType extends AbstractType { return ( EntityMode.POJO == entityPersister.getEntityMode() ) ? entityPersister.getMappedClass() : entityName; } + @Override public void nullSafeSet( PreparedStatement st, Object value, @@ -80,6 +86,7 @@ public class DiscriminatorType extends AbstractType { nullSafeSet( st, value, index, session ); } + @Override public void nullSafeSet( PreparedStatement st, Object value, @@ -90,26 +97,31 @@ public class DiscriminatorType extends AbstractType { underlyingType.nullSafeSet(st, entityPersister.getDiscriminatorValue(), index, session); } + @Override public String toLoggableString(Object value, SessionFactoryImplementor factory) throws HibernateException { return value == null ? "[null]" : value.toString(); } + @Override public Object deepCopy(Object value, SessionFactoryImplementor factory) throws HibernateException { return value; } + @Override public Object replace(Object original, Object target, SharedSessionContractImplementor session, Object owner, Map copyCache) throws HibernateException { return original; } + @Override public boolean[] toColumnNullness(Object value, Mapping mapping) { return value == null ? ArrayHelper.FALSE : ArrayHelper.TRUE; } + @Override public boolean isDirty(Object old, Object current, boolean[] checkable, SharedSessionContractImplementor session) throws HibernateException { return Objects.equals( old, current ); @@ -118,6 +130,7 @@ public class DiscriminatorType extends AbstractType { // simple delegation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + @Override public int[] sqlTypes(Mapping mapping) throws MappingException { return underlyingType.sqlTypes( mapping ); } @@ -132,6 +145,7 @@ public class DiscriminatorType extends AbstractType { return underlyingType.defaultSizes( mapping ); } + @Override public int getColumnSpan(Mapping mapping) throws MappingException { return underlyingType.getColumnSpan( mapping ); } diff --git a/hibernate-core/src/main/java/org/hibernate/type/AbstractType.java b/hibernate-core/src/main/java/org/hibernate/type/AbstractType.java index 14adc63b95..c61dd34f41 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/AbstractType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/AbstractType.java @@ -19,33 +19,39 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor; /** * Abstract superclass of the built in Type hierarchy. - * + * * @author Gavin King */ public abstract class AbstractType implements Type { protected static final Size LEGACY_DICTATED_SIZE = new Size(); protected static final Size LEGACY_DEFAULT_SIZE = new Size( 19, 2, 255, Size.LobMultiplier.NONE ); // to match legacy behavior + @Override public boolean isAssociationType() { return false; } + @Override public boolean isCollectionType() { return false; } + @Override public boolean isComponentType() { return false; } + @Override public boolean isEntityType() { return false; } - + + @Override public int compare(Object x, Object y) { return ( (Comparable) x ).compareTo(y); } + @Override public Serializable disassemble(Object value, SharedSessionContractImplementor session, Object owner) throws HibernateException { @@ -57,6 +63,7 @@ public abstract class AbstractType implements Type { } } + @Override public Object assemble(Serializable cached, SharedSessionContractImplementor session, Object owner) throws HibernateException { if ( cached==null ) { @@ -67,10 +74,12 @@ public abstract class AbstractType implements Type { } } + @Override public boolean isDirty(Object old, Object current, SharedSessionContractImplementor session) throws HibernateException { return !isSame( old, current ); } + @Override public Object hydrate( ResultSet rs, String[] names, @@ -82,56 +91,67 @@ public abstract class AbstractType implements Type { return nullSafeGet(rs, names, session, owner); } + @Override public Object resolve(Object value, SharedSessionContractImplementor session, Object owner) throws HibernateException { return value; } - public Object semiResolve(Object value, SharedSessionContractImplementor session, Object owner) + @Override + public Object semiResolve(Object value, SharedSessionContractImplementor session, Object owner) throws HibernateException { return value; } - + + @Override public boolean isAnyType() { return false; } + @Override public boolean isModified(Object old, Object current, boolean[] checkable, SharedSessionContractImplementor session) throws HibernateException { return isDirty(old, current, session); } - + + @Override public boolean isSame(Object x, Object y) throws HibernateException { return isEqual(x, y ); } + @Override public boolean isEqual(Object x, Object y) { return Objects.equals( x, y ); } - + + @Override public int getHashCode(Object x) { return x.hashCode(); } + @Override public boolean isEqual(Object x, Object y, SessionFactoryImplementor factory) { return isEqual(x, y ); } - + + @Override public int getHashCode(Object x, SessionFactoryImplementor factory) { return getHashCode(x ); } - + + @Override public Type getSemiResolvedType(SessionFactoryImplementor factory) { return this; } + @Override public Object replace( - Object original, - Object target, - SharedSessionContractImplementor session, - Object owner, - Map copyCache, - ForeignKeyDirection foreignKeyDirection) + Object original, + Object target, + SharedSessionContractImplementor session, + Object owner, + Map copyCache, + ForeignKeyDirection foreignKeyDirection) throws HibernateException { boolean include; if ( isAssociationType() ) { @@ -144,6 +164,7 @@ public abstract class AbstractType implements Type { return include ? replace(original, target, session, owner, copyCache) : target; } + @Override public void beforeAssemble(Serializable cached, SharedSessionContractImplementor session) {} /*public Object copy(Object original, Object target, SharedSessionContractImplementor session, Object owner, Map copyCache)