-
-
Couldn't load subscription status.
- Fork 3.7k
Introduce Java types for SQL Interval types #4892
-
The SQL Standard has interval X and interval X to Y types, which can be seen as wrappers around numeric where the Y part is the fractional part. I propose to add Java types to Hibernate for these interval types, which extend java.lang.Number. These special types will receive some methods to interact with Temporal types and map to the corresponding SQL interval types, or numeric/decimal as fallback.
Since Oracle only supports 2 interval types, I would suggest we limit ourselves to these for now:
YearToMonthIntervalforinterval year to monthDayToSecondIntervalforinterval day to secondfor a precision up to nanoseconds
We can add others later though if needed and emulate these through the numeric type then.
As a side note, we already support the type interval second which java.time.Duration maps to if possible.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 2 comments 2 replies
-
According to our existing ideology, this wouldn’t belong in core, but in something analogous to hibernate-spatial or that hibernate types project i have never looked at.
Of course, ideology can change...
Beta Was this translation helpful? Give feedback.
All reactions
-
I propose we add a new sub module to Hibernate for these things and propose the module name hibernate-types for the lack of a better idea for a name 😆
I know @jwgmeligmeyling is eager to contribute a range type for mapping PostgreSQL tsrange, so such a module would be the perfect place for that.
Beta Was this translation helpful? Give feedback.
All reactions
-
module name hibernate-types for the lack of a better idea for a name
hibernate-extras?
Beta Was this translation helpful? Give feedback.
All reactions
-
FYI, I introduced the hibernate-types submodule as part of #7506
If you hate the name, please speak up on Zulip.
Beta Was this translation helpful? Give feedback.