Skip to content

Commit 186e1d4

Browse files
committed
HHH-19669 hql insert fails for entity with join inheritance on Oracle
1 parent 327ba51 commit 186e1d4

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/cte/CteInsertHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ protected String addDmlCtes(
702702

703703
final Generator identifierGenerator = entityDescriptor.getEntityPersister().getGenerator();
704704
final List<Map.Entry<List<CteColumn>, Assignment>> tableAssignments = assignmentsByTable.get( rootTableReference );
705-
if ( ( tableAssignments == null || tableAssignments.isEmpty() )
705+
if ( !assignsId && ( tableAssignments == null || tableAssignments.isEmpty() )
706706
&& !identifierGenerator.generatedOnExecution() ) {
707707
throw new IllegalStateException( "There must be at least a single root table assignment" );
708708
}

hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/temptable/InsertExecutionDelegate.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ public int execute(ExecutionContext executionContext) {
217217
);
218218

219219
if ( rows != 0 ) {
220-
final EntityPersister persister = entityDescriptor.getEntityPersister();
220+
final EntityPersister persister = entityDescriptor.getEntityPersister();
221221
final int tableSpan = persister.getTableSpan();
222222
final int insertedRows = insertRootTable(
223223
persister.getTableName( 0 ),
@@ -316,10 +316,11 @@ private int insertRootTable(
316316
final EntityPersister entityPersister = entityDescriptor.getEntityPersister();
317317
final Generator generator = entityPersister.getGenerator();
318318
final List<Assignment> assignments = assignmentsByTable.get( tableExpression );
319-
if ( ( assignments == null || assignments.isEmpty() )
320-
&& !generator.generatedOnExecution()
321-
&& ( !( generator instanceof BulkInsertionCapableIdentifierGenerator )
322-
|| ( (BulkInsertionCapableIdentifierGenerator) generator ).supportsBulkInsertionIdentifierGeneration() ) ) {
319+
if ( !assignsId
320+
&& (assignments == null || assignments.isEmpty())
321+
&& !generator.generatedOnExecution()
322+
&& (!(generator instanceof BulkInsertionCapableIdentifierGenerator)
323+
|| ((BulkInsertionCapableIdentifierGenerator) generator).supportsBulkInsertionIdentifierGeneration()) ) {
323324
throw new IllegalStateException( "There must be at least a single root table assignment" );
324325
}
325326

0 commit comments

Comments
 (0)