|
101 | 101 | import org.hibernate.query.sqm.function.SelfRenderingFunctionSqlAstExpression; |
102 | 102 | import org.hibernate.query.sqm.sql.internal.BasicValuedPathInterpretation; |
103 | 103 | import org.hibernate.query.sqm.sql.internal.SqmParameterInterpretation; |
| 104 | +import org.hibernate.query.sqm.sql.internal.SqmPathInterpretation; |
104 | 105 | import org.hibernate.query.sqm.tree.expression.Conversion; |
105 | 106 | import org.hibernate.sql.ast.Clause; |
106 | 107 | import org.hibernate.sql.ast.SqlAstNodeRenderingMode; |
|
130 | 131 | import org.hibernate.sql.ast.tree.expression.Expression; |
131 | 132 | import org.hibernate.sql.ast.tree.expression.ExtractUnit; |
132 | 133 | import org.hibernate.sql.ast.tree.expression.Format; |
| 134 | +import org.hibernate.sql.ast.tree.expression.FunctionExpression; |
133 | 135 | import org.hibernate.sql.ast.tree.expression.JdbcLiteral; |
134 | 136 | import org.hibernate.sql.ast.tree.expression.JdbcParameter; |
135 | 137 | import org.hibernate.sql.ast.tree.expression.Literal; |
|
169 | 171 | import org.hibernate.sql.ast.tree.predicate.LikePredicate; |
170 | 172 | import org.hibernate.sql.ast.tree.predicate.NegatedPredicate; |
171 | 173 | import org.hibernate.sql.ast.tree.predicate.NullnessPredicate; |
| 174 | +import org.hibernate.sql.ast.tree.predicate.Predicate; |
172 | 175 | import org.hibernate.sql.ast.tree.predicate.SelfRenderingPredicate; |
173 | 176 | import org.hibernate.sql.ast.tree.predicate.ThruthnessPredicate; |
174 | 177 | import org.hibernate.sql.ast.tree.select.QueryGroup; |
@@ -694,7 +697,8 @@ public void visitUpdateStatement(UpdateStatement updateStatement) { |
694 | 697 | var fieldPath = acceptAndYield(fieldReferences.get(0), FIELD_PATH); |
695 | 698 | var assignedValue = assignment.getAssignedValue(); |
696 | 699 | if (!isValueExpression(assignedValue)) { |
697 | | - throw new FeatureNotSupportedException(); |
| 700 | + throw new FeatureNotSupportedException( |
| 701 | + getUnsupportedUpdateValueAssignmentMessage(fieldPath, assignedValue)); |
698 | 702 | } |
699 | 703 | var fieldValue = acceptAndYield(assignedValue, VALUE); |
700 | 704 | fieldUpdates.add(new AstFieldUpdate(fieldPath, fieldValue)); |
@@ -1205,4 +1209,19 @@ public void appendSql(String fragment) { |
1205 | 1209 | throw new FeatureNotSupportedException(); |
1206 | 1210 | } |
1207 | 1211 | } |
| 1212 | + |
| 1213 | + private static String getUnsupportedUpdateValueAssignmentMessage(final String fieldPath, Expression assignedValue) { |
| 1214 | + if (assignedValue instanceof FunctionExpression ex) { |
| 1215 | + return "Function expression [%s] as update assignment value for field path [%s] is not supported" |
| 1216 | + .formatted(ex.getFunctionName(), fieldPath); |
| 1217 | + } else if (assignedValue instanceof Predicate) { |
| 1218 | + return "Predicate expression as update assignment value for field path [%s] is not supported" |
| 1219 | + .formatted(fieldPath); |
| 1220 | + } else if (assignedValue instanceof SqmPathInterpretation) { |
| 1221 | + return "Path expression as update assignment value for field path [%s] is not supported" |
| 1222 | + .formatted(fieldPath); |
| 1223 | + } else { |
| 1224 | + return "Update assignment value for field path [%s] is not supported".formatted(fieldPath); |
| 1225 | + } |
| 1226 | + } |
1208 | 1227 | } |
0 commit comments