Skip to content

Commit 145ad4b

Browse files
committed
HHH-19579 Criteria update join - Column 'code' in SET is ambiguous
1 parent 43fc5c7 commit 145ad4b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

hibernate-core/src/main/java/org/hibernate/sql/ast/spi/AbstractSqlAstTranslator.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,7 @@ protected void renderSetClause(List<Assignment> assignments) {
12051205
protected void visitSetAssignment(Assignment assignment) {
12061206
final List<ColumnReference> columnReferences = assignment.getAssignable().getColumnReferences();
12071207
if ( columnReferences.size() == 1 ) {
1208-
columnReferences.get( 0 ).appendColumnForWrite( this, null );
1208+
appendColumn( columnReferences.get( 0 ) );
12091209
appendSql( '=' );
12101210
final Expression assignedValue = assignment.getAssignedValue();
12111211
final SqlTuple sqlTuple = SqlTupleContainer.getSqlTuple( assignedValue );
@@ -1221,14 +1221,21 @@ protected void visitSetAssignment(Assignment assignment) {
12211221
char separator = OPEN_PARENTHESIS;
12221222
for ( ColumnReference columnReference : columnReferences ) {
12231223
appendSql( separator );
1224-
columnReference.appendColumnForWrite( this, null );
1224+
appendColumn( columnReference );
12251225
separator = COMMA_SEPARATOR_CHAR;
12261226
}
12271227
appendSql( ")=" );
12281228
assignment.getAssignedValue().accept( this );
12291229
}
12301230
}
12311231

1232+
protected void appendColumn(ColumnReference column) {
1233+
column.appendColumnForWrite(
1234+
this,
1235+
affectedTableNames.size() > 1 ? determineColumnReferenceQualifier( column ) : null
1236+
);
1237+
}
1238+
12321239
protected void visitSetAssignmentEmulateJoin(Assignment assignment, UpdateStatement statement) {
12331240
final List<ColumnReference> columnReferences = assignment.getAssignable().getColumnReferences();
12341241
final Expression valueExpression;

0 commit comments

Comments
 (0)