give UserType.replace() a sensible default impl that's essentially always correct

This commit is contained in:
Gavin 2023-01-06 12:15:36 +01:00
parent fe9f909dce
commit 5fb04fb6f6
4 changed files with 3 additions and 23 deletions

View File

@ -94,11 +94,5 @@ public class BitSetUserType implements UserType<BitSet> {
public BitSet assemble(Serializable cached, Object owner) {
return deepCopy((BitSet) cached);
}
@Override
public BitSet replace(BitSet original, BitSet target, Object owner)
throws HibernateException {
return deepCopy(original);
}
}
//end::basic-custom-type-BitSetUserType-example[]

View File

@ -112,9 +112,4 @@ public abstract class BaseUserTypeSupport<T> implements UserType<T> {
public T assemble(Serializable cached, Object owner) throws HibernateException {
return javaType().getMutabilityPlan().assemble( cached, null );
}
@Override
public T replace(T original, T target, Object owner) throws HibernateException {
return deepCopy( original );
}
}

View File

@ -158,10 +158,4 @@ public class StaticUserTypeSupport<T> implements UserType<T> {
public T assemble(Serializable cached, Object owner) throws HibernateException {
return javaType.getMutabilityPlan().assemble( cached, null );
}
@Override
public T replace(T original, T target, Object owner) throws HibernateException {
return deepCopy( original );
}
}

View File

@ -102,11 +102,6 @@ import org.hibernate.type.spi.TypeConfiguration;
* public Period assemble(Serializable cached, Object owner) {
* return (Period) cached; //Period is immutable
* }
*
* &#64;Override
* public Period replace(Period detached, Period managed, Object owner) {
* return detached;
* }
* }
* </pre>
* <p>
@ -395,7 +390,9 @@ public interface UserType<J> {
*
* @see org.hibernate.Session#merge(Object)
*/
J replace(J detached, J managed, Object owner);
default J replace(J detached, J managed, Object owner) {
return deepCopy( detached );
}
/**
* The default column length, for use in DDL generation.