Closed gavinking closed 2 years ago
This looks like a good, sound enhancement that dovetails nicely with what is happening in Java SE. I hope it makes it into the next specification revision.
(Note that as a subtask of this issue, we would clarify the types of datetime expressions.)
Sounds good to me!
Currently the JPA spec defines
current_date
,current_time
, andcurrent_timestamp
, which have been interpreted by implementations to be of typejava.sql.Date
,java.sql.time
, andjava.sql.Timestamp
respectively (even though it seems that the JPA spec leaves this unspecified!).The problem is that
java.sql.Date
,java.sql.time
, andjava.sql.Timestamp
are essentially deprecated and replaced by the types injava.time
.Hibernate 6 supports the syntax
local date
,local time
, andlocal datetime
, along withlocal_date
,local_time
, andlocal_datetime
which are considered to have type
LocalTime
,LocalDate
, andLocalDateTime
respectively.I prefer the versions without the underscores because they look more consistent with the rest of the language, which doesn't use underscores anywhere (e.g. we don't write
order_by
orinner_join
, nor do we writealias.created_time
to refer to a field of an entity).I believe that similar functionality should be added to the JPA spec.
An alternative approach would be to introduce some sort of setting which changed the interpretation of the existing syntax
current_date
,current_time
, andcurrent_timestamp
, but I think this option is inferior.Thoughts?