Add java.time option to Entity Classes from Database wizard#9448
Open
renatsaf wants to merge 1 commit into
Open
Add java.time option to Entity Classes from Database wizard#9448renatsaf wants to merge 1 commit into
renatsaf wants to merge 1 commit into
Conversation
The "Entity Classes from Database" wizard always mapped temporal columns (DATE/TIME/TIMESTAMP) to java.util.Date with a @TeMPOraL annotation. Add a "Date/Time API" mapping option, alongside the existing Collection Type option, that lets the user choose java.time types instead: java.sql.Date -> java.time.LocalDate java.sql.Time -> java.time.LocalTime java.sql.Timestamp -> java.time.LocalDateTime java.time types are mapped natively by JPA 2.2+, so no @TeMPOraL annotation is emitted for them. The default stays java.util.Date for backward compatibility. Fixes apache#3755 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2 tasks
mbien
reviewed
Jun 17, 2026
mbien
left a comment
Member
There was a problem hiding this comment.
only took a quick glance: one thing to watch out for is that both entitygenerator and wizard/formdb packages are exported to friends. So its API essentially (although not completely public). But it looks like MappingOptionsPanel#initialize could be overloaded so that the old signature remains in place. (it might have been made public by mistake)
the friends list is small, in theory we could ask around but it is probably not worth it for this situation
cc @matthiasblaesing who has more experience with those details
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The Entity Classes from Database wizard always mapped temporal columns (
DATE/TIME/TIMESTAMP) tojava.util.Datewith a@Temporalannotation, forcing users to refactor the generated entities by hand.This adds a Date/Time API mapping option, sitting next to the existing Collection Type option (the UI pattern requested in the issue), letting the user choose
java.timetypes instead:java.timejava.sql.Datejava.time.LocalDatejava.sql.Timejava.time.LocalTimejava.sql.Timestampjava.time.LocalDateTimejava.timetypes are mapped natively by JPA 2.2+, so no@Temporalannotation is emitted for them.The default remains
java.util.Date, so existing behavior is unchanged unless the user opts in.How
DateTimeTypeenum (LEGACY/JAVA_8) in theentitygeneratorpackage.RelatedCMPHelpercarries the choice;MappingOptionsPanelexposes the combo box and wires it throughreadSettings/storeSettings, mirroringCollectionType.JavaPersistenceGenerator.getMemberType()/getMemberTemporalType()branch on the selected family;@Temporalis suppressed forjava.time.f1_jpa005.htm) documents the new option.Test
JPAGenTestcases updated for the new parameter.JPAGenTest.testGenerateJavaTimeTypesgenerates an entity withDATE/TIME/TIMESTAMPcolumns underJAVA_8and asserts the generated source uses thejava.timetypes and contains nojava.util.Dateor@Temporal.Fixes #3755
🤖 Generated with Claude Code