Skip to content

Fix invalid JPQL emitted by JPAInsertClause set() style (#1718)#1719

Open
zio0911 wants to merge 1 commit into
OpenFeign:masterfrom
zio0911:fix/jpa-insert-set-style-1718
Open

Fix invalid JPQL emitted by JPAInsertClause set() style (#1718)#1719
zio0911 wants to merge 1 commit into
OpenFeign:masterfrom
zio0911:fix/jpa-insert-set-style-1718

Conversation

@zio0911
Copy link
Copy Markdown

@zio0911 zio0911 commented Apr 29, 2026

Summary

Fixes #1718. JPAInsertClause/HibernateInsertClause .set(path, value) calls were producing invalid JPQL (path = value pairs after the column list) which Hibernate rejected with SyntaxException. The serializer now emits a proper VALUES (...) clause for the inserts map, matching the existing column list order (LinkedHashMap).

Before

insert into Cat (name, alive)
cat.name = ?1, cat.alive = ?2

org.hibernate.query.SyntaxException: At 2:0 and token 'cat', mismatched input 'cat', expecting one of the following tokens: '(', FROM, ORDER, SELECT, VALUES, WHERE, WITH

After

insert into Cat (name, alive)
values (?1, ?2)

Scope

  • JPQLSerializer.serializeForInsert — converts the inserts map to a VALUES list instead of path = value pairs
  • columns().values() style and INSERT ... SELECT (sub-query) paths are unchanged

Test plan

  • New unit tests in JPQLSerializerTest:
    • serializeForInsert_setStyle_emitsValuesForm — verifies set()-style now emits VALUES (...) and no path = value
    • serializeForInsert_columnsValuesStyle_unchanged — guards the columns().values() path
  • ./mvnw -pl querydsl-libraries/querydsl-jpa -Pno-databases test — 368 tests pass

JPQLSerializer.serializeForInsert was emitting `path = value` pairs
for the set()-style inserts map, producing invalid JPQL like:

    insert into Cat (name, alive)
    cat.name = ?1, cat.alive = ?2

Hibernate rejected this with SyntaxException because JPQL/HQL only
supports the VALUES form (and INSERT ... SELECT) — there is no SET
form for INSERT.

Convert the inserts map to a VALUES (...) list using the same
iteration order as the column list (LinkedHashMap), producing valid:

    insert into Cat (name, alive)
    values (?1, ?2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JPAInsertClause/HibernateInsertClause .set() style produces invalid JPQL

2 participants