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 @@ -1095,6 +1095,8 @@ public LockingSupport getLockingSupport() {

@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 @@ -1103,7 +1103,16 @@ public boolean supportsLobValueChangePropagation() {
}

@Override
public boolean useInputStreamToInsertBlob() {
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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.hibernate.dialect.DatabaseVersion;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.DmlTargetColumnQualifierSupport;
import org.hibernate.dialect.OracleServerConfiguration;
import org.hibernate.dialect.temptable.OracleLocalTemporaryTableStrategy;
import org.hibernate.dialect.temptable.StandardGlobalTemporaryTableStrategy;
import org.hibernate.dialect.temptable.TemporaryTableStrategy;
Expand Down Expand Up @@ -206,20 +207,58 @@ protected void applyAggregateColumnCheck(StringBuilder buf, AggregateColumn aggr
}
};

// 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;

private final LockingSupport lockingSupport;

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

public OracleLegacyDialect(DatabaseVersion version) {
super(version);
super( version );
lockingSupport = new OracleLockingSupport( 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 );
lockingSupport = new OracleLockingSupport( getVersion() );
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 @@ -1662,11 +1701,11 @@ 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 appendCheckConstraintOptions(CheckConstraint checkConstraint, String sqlCheckConstraint) {
if ( StringHelper.isNotEmpty( checkConstraint.getOptions() ) ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,8 @@ public GenerationType getNativeValueGenerationStrategy() {

@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 @@ -993,6 +993,8 @@ public String getForUpdateSkipLockedString(String aliases) {

@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 @@ -939,7 +939,16 @@ public boolean supportsLobValueChangePropagation() {
}

@Override
public boolean useInputStreamToInsertBlob() {
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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1811,11 +1811,11 @@ 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 appendCheckConstraintOptions(CheckConstraint checkConstraint, String sqlCheckConstraint) {
return isNotEmpty( checkConstraint.getOptions() )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,8 @@ public GenerationType getNativeValueGenerationStrategy() {

@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 @@ -89,6 +89,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 @@ -108,7 +109,7 @@ public void testGenerateProxyStream() throws URISyntaxException {
// H2, MySQL, Oracle, SQL Server work this way.
//
//
Blob blob = BlobProxy.generateProxy( stream, 9192L );
Blob blob = BlobProxy.generateProxy( stream, length );

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