Fix problem with DB2, PostgerSQL with CTE table names for quoted tables
This commit is contained in:
parent
3f87ed17ee
commit
39ee0236be
|
@ -15,6 +15,7 @@ import java.util.Map;
|
|||
|
||||
import org.hibernate.LockMode;
|
||||
import org.hibernate.LockOptions;
|
||||
import org.hibernate.boot.model.naming.Identifier;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.metamodel.mapping.EntityMappingType;
|
||||
|
@ -298,4 +299,16 @@ public abstract class AbstractCteMutationHandler extends AbstractMutationHandler
|
|||
return tableGroup.getTableReference( tableGroup.getNavigablePath(), tableExpression );
|
||||
}
|
||||
}
|
||||
|
||||
protected String getCteTableName(String tableExpression) {
|
||||
if ( Identifier.isQuoted( tableExpression ) ) {
|
||||
tableExpression = unquote( tableExpression );
|
||||
return DML_RESULT_TABLE_NAME_PREFIX + tableExpression;
|
||||
}
|
||||
return DML_RESULT_TABLE_NAME_PREFIX + tableExpression;
|
||||
}
|
||||
|
||||
private String unquote(String tableExpression) {
|
||||
return tableExpression.substring( 1, tableExpression.length() - 1 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ public class CteDeleteHandler extends AbstractCteMutationHandler implements Dele
|
|||
// collection table
|
||||
final String tableExpression = pluralAttribute.getSeparateCollectionTable();
|
||||
final CteTable dmlResultCte = new CteTable(
|
||||
DML_RESULT_TABLE_NAME_PREFIX + tableExpression,
|
||||
getCteTableName( tableExpression ),
|
||||
idSelectCte.getCteTable().getCteColumns(),
|
||||
factory
|
||||
);
|
||||
|
@ -97,7 +97,7 @@ public class CteDeleteHandler extends AbstractCteMutationHandler implements Dele
|
|||
getEntityDescriptor().visitConstraintOrderedTables(
|
||||
(tableExpression, tableColumnsVisitationSupplier) -> {
|
||||
final CteTable dmlResultCte = new CteTable(
|
||||
DML_RESULT_TABLE_NAME_PREFIX + tableExpression,
|
||||
getCteTableName( tableExpression ),
|
||||
idSelectCte.getCteTable().getCteColumns(),
|
||||
factory
|
||||
);
|
||||
|
|
|
@ -140,7 +140,7 @@ public class CteUpdateHandler extends AbstractCteMutationHandler implements Upda
|
|||
getEntityDescriptor().visitConstraintOrderedTables(
|
||||
(tableExpression, tableColumnsVisitationSupplier) -> {
|
||||
final CteTable dmlResultCte = new CteTable(
|
||||
DML_RESULT_TABLE_NAME_PREFIX + tableExpression,
|
||||
getCteTableName( tableExpression ),
|
||||
idSelectCte.getCteTable().getCteColumns(),
|
||||
factory
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue