Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,8 @@ public boolean supportsOuterJoinForUpdate() {

@Override
public boolean useInputStreamToInsertBlob() {
// PG-JDBC treats setBinaryStream()/setCharacterStream() calls like bytea/varchar, which are not LOBs,
// so disable stream bindings for this dialect completely
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,20 @@ public boolean supportsLobValueChangePropagation() {
return false;
}

@Override
public boolean useConnectionToCreateLob() {
return false;
}

@Override
public boolean supportsNationalizedMethods() {
// See HHH-12753, HHH-18314, HHH-19201
// Old DB2 JDBC drivers do not support setNClob, setNCharcterStream or setNString.
// In more recent driver versions, some methods just delegate to the non-N variant, but others still fail.
// Ultimately, let's just avoid the N variant methods on DB2 altogether
return false;
}

@Override
public boolean doesReadCommittedCauseWritersToBlockReaders() {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.hibernate.dialect.DmlTargetColumnQualifierSupport;
import org.hibernate.dialect.DatabaseVersion;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.OracleServerConfiguration;
import org.hibernate.dialect.OracleBooleanJdbcType;
import org.hibernate.dialect.OracleJdbcHelper;
import org.hibernate.dialect.OracleJsonJdbcType;
Expand Down Expand Up @@ -188,16 +189,54 @@ public class OracleLegacyDialect extends Dialect {
private final UniqueDelegate uniqueDelegate = new CreateTableUniqueDelegate(this);
private final SequenceSupport oracleSequenceSupport = OracleSequenceSupport.getInstance(this);

// Is it an Autonomous Database Cloud Service?
protected final boolean autonomous;

// Is MAX_STRING_SIZE set to EXTENDED?
protected final boolean extended;

// Is the database accessed using a database service protected by Application Continuity.
protected final boolean applicationContinuity;

protected final int driverMajorVersion;
protected final int driverMinorVersion;

public OracleLegacyDialect() {
this( DatabaseVersion.make( 8, 0 ) );
}

public OracleLegacyDialect(DatabaseVersion version) {
super(version);
super( version );
autonomous = false;
extended = false;
applicationContinuity = false;
driverMajorVersion = 19;
driverMinorVersion = 0;
}

public OracleLegacyDialect(DialectResolutionInfo info) {
super(info);
this( info, OracleServerConfiguration.fromDialectResolutionInfo( info ) );
}

public OracleLegacyDialect(DialectResolutionInfo info, OracleServerConfiguration serverConfiguration) {
super( info );
autonomous = serverConfiguration.isAutonomous();
extended = serverConfiguration.isExtended();
applicationContinuity = serverConfiguration.isApplicationContinuity();
this.driverMinorVersion = serverConfiguration.getDriverMinorVersion();
this.driverMajorVersion = serverConfiguration.getDriverMajorVersion();
}

public boolean isAutonomous() {
return autonomous;
}

public boolean isExtended() {
return extended;
}

public boolean isApplicationContinuity() {
return applicationContinuity;
}

@Override
Expand Down Expand Up @@ -1587,10 +1626,10 @@ public boolean supportsFromClauseInUpdate() {

@Override
public boolean useInputStreamToInsertBlob() {
// see HHH-18206
return false;
// If application continuity is enabled, don't use stream bindings, since a replay could otherwise fail
// if the underlying stream doesn't support mark and reset
return !isApplicationContinuity();
}

@Override
public String getDual() {
return "dual";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,8 @@ public boolean supportsOuterJoinForUpdate() {

@Override
public boolean useInputStreamToInsertBlob() {
// PG-JDBC treats setBinaryStream()/setCharacterStream() calls like bytea/varchar, which are not LOBs,
// so disable stream bindings for this dialect completely
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,8 @@ public boolean supportsOuterJoinForUpdate() {

@Override
public boolean useInputStreamToInsertBlob() {
// PG-JDBC treats setBinaryStream()/setCharacterStream() calls like bytea/varchar, which are not LOBs,
// so disable stream bindings for this dialect completely
return false;
}

Expand Down
14 changes: 14 additions & 0 deletions hibernate-core/src/main/java/org/hibernate/dialect/DB2Dialect.java
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,20 @@ public boolean supportsLobValueChangePropagation() {
return false;
}

@Override
public boolean useConnectionToCreateLob() {
return false;
}

@Override
public boolean supportsNationalizedMethods() {
// See HHH-12753, HHH-18314, HHH-19201
// Old DB2 JDBC drivers do not support setNClob, setNCharcterStream or setNString.
// In more recent driver versions, some methods just delegate to the non-N variant, but others still fail.
// Ultimately, let's just avoid the N variant methods on DB2 altogether
return false;
}

@Override
public boolean doesReadCommittedCauseWritersToBlockReaders() {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1710,10 +1710,10 @@ public String[] getDropEnumTypeCommand(String name) {

@Override
public boolean useInputStreamToInsertBlob() {
// see HHH-18206
return false;
// If application continuity is enabled, don't use stream bindings, since a replay could otherwise fail
// if the underlying stream doesn't support mark and reset
return !isApplicationContinuity();
}

@Override
public String getDual() {
return "dual";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,8 @@ public boolean supportsOuterJoinForUpdate() {

@Override
public boolean useInputStreamToInsertBlob() {
// PG-JDBC treats setBinaryStream()/setCharacterStream() calls like bytea/varchar, which are not LOBs,
// so disable stream bindings for this dialect completely
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public void testGenerateProxyStream() throws URISyntaxException {
.getResource( "org/hibernate/orm/test/envers/integration/blob/blob.txt" ).toURI() );

try (final InputStream stream = new BufferedInputStream( Files.newInputStream( path ) )) {
final long length = Files.size( path );
doInJPA( this::entityManagerFactory, entityManager -> {
final Asset asset = new Asset();
asset.setFileName( "blob.txt" );
Expand All @@ -109,7 +110,7 @@ public void testGenerateProxyStream() throws URISyntaxException {
// H2, MySQL, Oracle, SQL Server work this way.
//
//
Blob blob = BlobProxy.generateProxy( stream, 1431 );
Blob blob = BlobProxy.generateProxy( stream, length );

asset.setData( blob );
entityManager.persist( asset );
Expand Down
Loading