mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-18 00:55:16 +00:00
HHH-18232 Use change table modifier new and final consistently on DB2 and zOS
This commit is contained in:
parent
de63a8dc00
commit
a6ffa84db7
@ -423,11 +423,19 @@ protected boolean renderReturningClause(MutationStatement statement) {
|
|||||||
appendSql( " from old table (" );
|
appendSql( " from old table (" );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
appendSql( " from final table (" );
|
appendSql( " from ");
|
||||||
|
appendSql( getNewTableChangeModifier() );
|
||||||
|
appendSql(" table (" );
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String getNewTableChangeModifier() {
|
||||||
|
// Use 'from new table' to also see data from triggers
|
||||||
|
// See https://www.ibm.com/docs/en/db2/10.5?topic=clause-table-reference#:~:text=FOR%20sequence%20reference-,FINAL%20TABLE,-Specifies%20that%20the
|
||||||
|
return "new";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitStandardTableInsert(TableInsertStandard tableInsert) {
|
public void visitStandardTableInsert(TableInsertStandard tableInsert) {
|
||||||
final List<ColumnReference> returningColumns = tableInsert.getReturningColumns();
|
final List<ColumnReference> returningColumns = tableInsert.getReturningColumns();
|
||||||
@ -441,7 +449,9 @@ public void visitStandardTableInsert(TableInsertStandard tableInsert) {
|
|||||||
appendSql( returningColumns.get( i ).getColumnExpression() );
|
appendSql( returningColumns.get( i ).getColumnExpression() );
|
||||||
}
|
}
|
||||||
|
|
||||||
appendSql( " from new table ( " ); // 'from final table' does not seem to play well with triggers
|
appendSql( " from ");
|
||||||
|
appendSql( getNewTableChangeModifier() );
|
||||||
|
appendSql(" table (" );
|
||||||
super.visitStandardTableInsert( tableInsert );
|
super.visitStandardTableInsert( tableInsert );
|
||||||
appendSql( ")" );
|
appendSql( ")" );
|
||||||
}
|
}
|
||||||
|
@ -84,6 +84,12 @@ public void visitFunctionTableReference(FunctionTableReference tableReference) {
|
|||||||
renderDerivedTableReference( tableReference );
|
renderDerivedTableReference( tableReference );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getNewTableChangeModifier() {
|
||||||
|
// On DB2 zOS, `final` also sees the trigger data
|
||||||
|
return "final";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DatabaseVersion getDB2Version() {
|
public DatabaseVersion getDB2Version() {
|
||||||
return DB2_LUW_VERSION9;
|
return DB2_LUW_VERSION9;
|
||||||
|
@ -421,11 +421,19 @@ protected boolean renderReturningClause(MutationStatement statement) {
|
|||||||
appendSql( " from old table (" );
|
appendSql( " from old table (" );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
appendSql( " from final table (" );
|
appendSql( " from ");
|
||||||
|
appendSql( getNewTableChangeModifier() );
|
||||||
|
appendSql(" table (" );
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String getNewTableChangeModifier() {
|
||||||
|
// Use 'from new table' to also see data from triggers
|
||||||
|
// See https://www.ibm.com/docs/en/db2/10.5?topic=clause-table-reference#:~:text=FOR%20sequence%20reference-,FINAL%20TABLE,-Specifies%20that%20the
|
||||||
|
return "new";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitStandardTableInsert(TableInsertStandard tableInsert) {
|
public void visitStandardTableInsert(TableInsertStandard tableInsert) {
|
||||||
final List<ColumnReference> returningColumns = tableInsert.getReturningColumns();
|
final List<ColumnReference> returningColumns = tableInsert.getReturningColumns();
|
||||||
@ -439,7 +447,9 @@ public void visitStandardTableInsert(TableInsertStandard tableInsert) {
|
|||||||
appendSql( returningColumns.get( i ).getColumnExpression() );
|
appendSql( returningColumns.get( i ).getColumnExpression() );
|
||||||
}
|
}
|
||||||
|
|
||||||
appendSql( " from new table (" ); // 'from final table' does not seem to play well with triggers
|
appendSql( " from ");
|
||||||
|
appendSql( getNewTableChangeModifier() );
|
||||||
|
appendSql(" table (" );
|
||||||
super.visitStandardTableInsert( tableInsert );
|
super.visitStandardTableInsert( tableInsert );
|
||||||
appendSql( ")" );
|
appendSql( ")" );
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,12 @@ public void visitFunctionTableReference(FunctionTableReference tableReference) {
|
|||||||
renderDerivedTableReference( tableReference );
|
renderDerivedTableReference( tableReference );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getNewTableChangeModifier() {
|
||||||
|
// On DB2 zOS, `final` also sees the trigger data
|
||||||
|
return "final";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DatabaseVersion getDB2Version() {
|
public DatabaseVersion getDB2Version() {
|
||||||
return DB2_LUW_VERSION;
|
return DB2_LUW_VERSION;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user