Branch: refs/heads/main
Home:
https://github.com/hibernate/hibernate-orm
Commit: fd5bbf5d419200e1815a8c35a2085b82ad40ae3a
https://github.com/hibernate/hibernate-orm/commit/fd5bbf5d419200e1815a8c3...
Author: Jan Schatteman <jrenaat(a)users.noreply.github.com>
Date: 2026-08-24 (Mon, 24 Aug 2026)
Changed paths:
A design/working/sql_formatting_constraints.adoc
M hibernate-core/hibernate-core.gradle
A hibernate-core/src/main/antlr/org/hibernate/grammars/sql/SqlFormatterLexer.g4
A hibernate-core/src/main/antlr/org/hibernate/grammars/sql/SqlFormatterParser.g4
A
hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/AntlrBasedSQLFormatterImpl.java
M hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/FormatStyle.java
A
hibernate-core/src/test/java/org/hibernate/orm/test/jdbc/util/AntlrBasedSQLFormatterTest.java
M
hibernate-core/src/test/java/org/hibernate/orm/test/jdbc/util/BasicFormatterTest.java
A
hibernate-core/src/test/resources/org/hibernate/orm/test/jdbc/util/dml_sql_fixtures.txt
M local-build-plugins/src/main/java/org/hibernate/orm/antlr/AntlrPlugin.java
Log Message:
-----------
HHH-15125 - Add ANTLR-based SQL formatter implementation (#12376)
* HHH-15125 - Add ANTLR-based SQL formatter implementation
Implement TokenBasedFormatterImpl as an improved SQL formatter using
ANTLR for tokenization.
Signed-off-by: Jan Schatteman <jschatte(a)redhat.com>
* HHH-15125 - Reimplemented the TokenBasedFormatterTest
Extracted the SQL Strings into a text file, which is much more readable than having
them sitting in the test class itself, with text blocks and line breaks and tab characters
and everything, which is cumbersome to edit and read
Signed-off-by: Jan Schatteman <jschatte(a)redhat.com>
* HHH-15125 - Add more SQL keywords and fixtures to cover insert/update statements'and
the necessary implementation changes to make them all pass
Signed-off-by: Jan Schatteman <jschatte(a)redhat.com>
* HHH-15125 - Added some more keywords, fixtures and implementation related to
delete/truncate statements
Signed-off-by: Jan Schatteman <jschatte(a)redhat.com>
* HHH-15125 - Sql formatter code cleanup and refactoring
Also, switch from tabs (\t) to spaces for indenting
Signed-off-by: Jan Schatteman <jschatte(a)redhat.com>
* HHH-15125 - Some additional corrections plus a new test
Signed-off-by: Jan Schatteman <jschatte(a)redhat.com>
* HHH-15125 - Get rid of another SonarQube warning, and add a few more missing keywords
Signed-off-by: Jan Schatteman <jschatte(a)redhat.com>
* HHH-15125 - Revert uppercasing of keywords, functions, boolean literals, etc. because
Hibernate hasn't use this style for a long time
Signed-off-by: Jan Schatteman <jschatte(a)redhat.com>
* HHH-15125 - Allow ignoring fixtures by commenting out (with '--') their ID
Signed-off-by: Jan Schatteman <jschatte(a)redhat.com>
* HHH-15125 - Some refactoring and improvements following in-depth analysis by Christian
Added some new tests as a result
Corrected a few errors
Signed-off-by: Jan Schatteman <jschatte(a)redhat.com>
* HHH-15125 - Introduce contexts for top-level select, insert, update, delete and merge
statements
Signed-off-by: Jan Schatteman <jschatte(a)redhat.com>
* HHH-15125 - Add support for window functions
Signed-off-by: Jan Schatteman <jschatte(a)redhat.com>
* HHH-15125 - Reorder keywords in sql lexer grammar alphabetically
Update the constraints doc
Added another test for window syntaxis
Signed-off-by: Jan Schatteman <jschatte(a)redhat.com>
* HHH-15125 - Various fixes
- Allowed for comments to be included in the test fixtures file
- Added a couple of new keywords
- Fixed ORDER BY and GROUP BY multiline detection when the clause is the
last one in a query (i.e. not followed by OFFSET/FETCH/LIMIT or
HAVING/ORDER): SEMICOLON was missing from the terminator lists used by
shouldListBeMultiline(), causing the fallback commaCount > 3 check to
return false for exactly 4 items (3 commas).
- Added test fixtures order_by_multiline and group_by_multiline to cover
this case.
- Added test fixtures for postgresql's over (partition by) clause
Signed-off-by: Jan Schatteman <jschatte(a)redhat.com>
* HHH-15125 - Set the AntlrBasedSQLFormatterImpl as the default formatter
Signed-off-by: Jan Schatteman <jschatte(a)redhat.com>
---------
Signed-off-by: Jan Schatteman <jschatte(a)redhat.com>
To unsubscribe from these emails, change your notification settings at
https://github.com/hibernate/hibernate-orm/settings/notifications