HHH-11740 : Default MultiTableBulkIdStrategy for DB2 does not work with connection pools
(cherry picked from commit 061a1cae31
)
This commit is contained in:
parent
e6573ed623
commit
8433260f37
|
@ -6,6 +6,12 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.dialect;
|
package org.hibernate.dialect;
|
||||||
|
|
||||||
|
import org.hibernate.hql.spi.id.IdTableSupportStandardImpl;
|
||||||
|
import org.hibernate.hql.spi.id.MultiTableBulkIdStrategy;
|
||||||
|
import org.hibernate.hql.spi.id.global.GlobalTemporaryTableBulkIdStrategy;
|
||||||
|
import org.hibernate.hql.spi.id.local.AfterUseAction;
|
||||||
|
import org.hibernate.hql.spi.id.local.LocalTemporaryTableBulkIdStrategy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An SQL dialect for DB2 9.7.
|
* An SQL dialect for DB2 9.7.
|
||||||
*
|
*
|
||||||
|
@ -18,4 +24,29 @@ public class DB297Dialect extends DB2Dialect {
|
||||||
// DB2 9.7 and later support "cross join"
|
// DB2 9.7 and later support "cross join"
|
||||||
return " cross join ";
|
return " cross join ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MultiTableBulkIdStrategy getDefaultMultiTableBulkIdStrategy() {
|
||||||
|
// Starting in DB2 9.7, "real" global temporary tables that can be shared between sessions
|
||||||
|
// are supported; (obviously) data is not shared between sessions.
|
||||||
|
return new GlobalTemporaryTableBulkIdStrategy(
|
||||||
|
new IdTableSupportStandardImpl() {
|
||||||
|
@Override
|
||||||
|
public String generateIdTableName(String baseName) {
|
||||||
|
return super.generateIdTableName( baseName );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCreateIdTableCommand() {
|
||||||
|
return "create global temporary table";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCreateIdTableStatementOptions() {
|
||||||
|
return "not logged";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
AfterUseAction.CLEAN
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ import org.hibernate.hql.spi.id.IdTableSupportStandardImpl;
|
||||||
import org.hibernate.hql.spi.id.MultiTableBulkIdStrategy;
|
import org.hibernate.hql.spi.id.MultiTableBulkIdStrategy;
|
||||||
import org.hibernate.hql.spi.id.global.GlobalTemporaryTableBulkIdStrategy;
|
import org.hibernate.hql.spi.id.global.GlobalTemporaryTableBulkIdStrategy;
|
||||||
import org.hibernate.hql.spi.id.local.AfterUseAction;
|
import org.hibernate.hql.spi.id.local.AfterUseAction;
|
||||||
|
import org.hibernate.hql.spi.id.local.LocalTemporaryTableBulkIdStrategy;
|
||||||
import org.hibernate.internal.CoreLogging;
|
import org.hibernate.internal.CoreLogging;
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
import org.hibernate.internal.util.JdbcExceptionHelper;
|
import org.hibernate.internal.util.JdbcExceptionHelper;
|
||||||
|
@ -379,7 +380,10 @@ public class DB2Dialect extends Dialect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MultiTableBulkIdStrategy getDefaultMultiTableBulkIdStrategy() {
|
public MultiTableBulkIdStrategy getDefaultMultiTableBulkIdStrategy() {
|
||||||
return new GlobalTemporaryTableBulkIdStrategy(
|
// Prior to DB2 9.7, "real" global temporary tables that can be shared between sessions
|
||||||
|
// are *not* supported; even though the DB2 command says to declare a "global" temp table
|
||||||
|
// Hibernate treats it as a "local" temp table.
|
||||||
|
return new LocalTemporaryTableBulkIdStrategy(
|
||||||
new IdTableSupportStandardImpl() {
|
new IdTableSupportStandardImpl() {
|
||||||
@Override
|
@Override
|
||||||
public String generateIdTableName(String baseName) {
|
public String generateIdTableName(String baseName) {
|
||||||
|
@ -396,7 +400,8 @@ public class DB2Dialect extends Dialect {
|
||||||
return "not logged";
|
return "not logged";
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
AfterUseAction.CLEAN
|
AfterUseAction.DROP,
|
||||||
|
null
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue