Initially when I started working on 6.0 I added support for defining temporal literals using JDBC's "escape syntax". JDBC already defines a syntax for declaring temporal literals using this syntax -
- {d '2020-01-01'} for a Date - {t '10:10:10'} for a Time - {ts '2020-01-01 10:10:10'} for a Timestamp I had planned on using this syntax to define generalized support for adding new types of literals using the "prefix" which is the first identifier after the open brace. I did not have any concrete plans for specific types of literals, although I was hoping this would fit with hibernate-spatial needs. Since temporal values are so common I added another simplified form: - {2020-01-01} for a "Date" - {10:10:10} for a "Time" - {2020-01-01 10:10:10} for a "Timestamp" Notice first the absence of quotes for these. The patterns is defined as a syntactic element of the grammar (thanks to Gavin King for this particular idea)[1]. As a side note, I first tried to use back-ticks for these simplified temporal literals rather than braces but that conflicts with the `QUOTED_IDENTIFIER` lexer rule. `QUOTED_IDENTIFIER` is never used (and really kind of meaningless in the HQL grammar) so one option would be to remove that rule and use the back-ticks for these literals like `2020-01-01` as opposed to {2020-01-01} if folks like that better. It's also important to note that I actually use the Java 8 temporal types internally to represent these simplified literals because it is easy to translate from one type to another starting from these types. Anyone have objections or suggestions regarding any of this? [1] - https://github.com/hibernate/hibernate-orm/blob/eab6107ec2e7b3a0c06146a9ff51b9964f4b3169/hibernate-core/src/main/antlr/org/hibernate/grammars/hql/HqlParser.g4#L484 _______________________________________________ hibernate-dev mailing list hibernate-dev@lists.jboss.org https://lists.jboss.org/mailman/listinfo/hibernate-dev