Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Introduce Java types for SQL Interval types #4892

beikov started this conversation in Design Proposals
Discussion options

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:

  • YearToMonthInterval for interval year to month
  • DayToSecondInterval for interval day to second for 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.

You must be logged in to vote

Replies: 2 comments 2 replies

Comment options

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...

You must be logged in to vote
0 replies
Comment options

beikov
Dec 14, 2022
Maintainer Author

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.

You must be logged in to vote
2 replies
Comment options

module name hibernate-types for the lack of a better idea for a name

hibernate-extras?

Comment options

beikov Nov 7, 2023
Maintainer Author

FYI, I introduced the hibernate-types submodule as part of #7506

If you hate the name, please speak up on Zulip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /