HHH-12555 : Remove code in LobMergeStrategy implementations that copied original Lob when target is null
This commit is contained in:
parent
ca6dc226eb
commit
4d0b5dc184
|
@ -7,12 +7,8 @@
|
|||
package org.hibernate.type;
|
||||
|
||||
import java.sql.Blob;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.hibernate.engine.jdbc.LobCreator;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||
import org.hibernate.type.descriptor.java.BlobTypeDescriptor;
|
||||
|
||||
/**
|
||||
|
@ -40,23 +36,7 @@ public class BlobType extends AbstractSingleColumnStandardBasicType<Blob> {
|
|||
|
||||
@Override
|
||||
protected Blob getReplacement(Blob original, Blob target, SharedSessionContractImplementor session) {
|
||||
if ( target == null ) {
|
||||
return copyOriginalBlob( (Blob) original, session );
|
||||
}
|
||||
|
||||
return session.getJdbcServices().getJdbcEnvironment().getDialect().getLobMergeStrategy().mergeBlob( original, target, session );
|
||||
}
|
||||
|
||||
private Blob copyOriginalBlob(Blob original, SharedSessionContractImplementor session) {
|
||||
try {
|
||||
final LobCreator lobCreator = session.getFactory().getServiceRegistry().getService( JdbcServices.class ).getLobCreator(
|
||||
session );
|
||||
return original == null
|
||||
? lobCreator.createBlob( ArrayHelper.EMPTY_BYTE_ARRAY )
|
||||
: lobCreator.createBlob( original.getBinaryStream(), original.length() );
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw session.getJdbcServices().getSqlExceptionHelper().convert( e, "unable to merge BLOB data" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,10 +7,7 @@
|
|||
package org.hibernate.type;
|
||||
|
||||
import java.sql.Clob;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.hibernate.engine.jdbc.LobCreator;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.type.descriptor.java.ClobTypeDescriptor;
|
||||
|
||||
|
@ -39,21 +36,6 @@ public class ClobType extends AbstractSingleColumnStandardBasicType<Clob> {
|
|||
|
||||
@Override
|
||||
protected Clob getReplacement(Clob original, Clob target, SharedSessionContractImplementor session) {
|
||||
if ( target == null ) {
|
||||
return copyOriginalClob( (Clob) original, session );
|
||||
}
|
||||
return session.getJdbcServices().getJdbcEnvironment().getDialect().getLobMergeStrategy().mergeClob( (Clob) original, (Clob) target, session );
|
||||
}
|
||||
|
||||
private Clob copyOriginalClob(Clob original, SharedSessionContractImplementor session) {
|
||||
try {
|
||||
final LobCreator lobCreator = session.getFactory().getServiceRegistry().getService( JdbcServices.class ).getLobCreator( session );
|
||||
return original == null
|
||||
? lobCreator.createClob( "" )
|
||||
: lobCreator.createClob( original.getCharacterStream(), original.length() );
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw session.getJdbcServices().getSqlExceptionHelper().convert( e, "unable to merge CLOB data" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,10 +7,7 @@
|
|||
package org.hibernate.type;
|
||||
|
||||
import java.sql.NClob;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.hibernate.engine.jdbc.LobCreator;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.type.descriptor.java.NClobTypeDescriptor;
|
||||
|
||||
|
@ -39,21 +36,6 @@ public class NClobType extends AbstractSingleColumnStandardBasicType<NClob> {
|
|||
|
||||
@Override
|
||||
protected NClob getReplacement(NClob original, NClob target, SharedSessionContractImplementor session) {
|
||||
if ( target == null ) {
|
||||
return copyOriginalNClob( original, session );
|
||||
}
|
||||
return session.getJdbcServices().getJdbcEnvironment().getDialect().getLobMergeStrategy().mergeNClob( original, target, session );
|
||||
}
|
||||
|
||||
private NClob copyOriginalNClob(NClob original, SharedSessionContractImplementor session) {
|
||||
try {
|
||||
final LobCreator lobCreator = session.getFactory().getServiceRegistry().getService( JdbcServices.class ).getLobCreator( session );
|
||||
return original == null
|
||||
? lobCreator.createNClob( "" )
|
||||
: lobCreator.createNClob( original.getCharacterStream(), original.length() );
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw session.getJdbcServices().getSqlExceptionHelper().convert( e, "unable to merge NCLOB data" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue