Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update JSON type mapping with io.hypersistence:hypersistence-utils-hibernate #7

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

iuliiasobolevska
Copy link
Contributor

@iuliiasobolevska iuliiasobolevska commented Jul 5, 2023

What's changed?

@TypeDef and @TypeDefs annotations have been removed, source.
JSON type mapping changed in Hibernate 6 and hypersistence-utils 6, source.

What's your motivation?

Anything, in particular, you'd like reviewers to focus on?

Any OpenRewrite tips and tricks to make it more concise and beautify the code are highly appreciated.

Any additional context

Taking a cautious approach and only removing @TypeDef and @TypeDefs annotations when used in combination with hypersistence-utils.
This recipe doesn't cover list-alike type mapping.

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've added the license header to any new files through ./gradlew licenseFormat
  • I've used the IntelliJ auto-formatter on affected files

@iuliiasobolevska iuliiasobolevska force-pushed the issue-3-recipe-for-migrating-hypersistence-utils-types branch from d83839f to fd78548 Compare July 5, 2023 00:24
@iuliiasobolevska iuliiasobolevska force-pushed the issue-3-recipe-for-migrating-hypersistence-utils-types branch from fd78548 to 6724d68 Compare July 5, 2023 00:35
@knutwannheden knutwannheden added enhancement New feature or request recipe labels Jul 5, 2023
Copy link

@knutwannheden knutwannheden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! This already looks quite good. I have not yet reviewed the recipe in detail, but I've added a few comments to get you started.

return Preconditions.check(Preconditions.and(
new FindImports("org.hibernate.annotations.Type").getVisitor(),
Preconditions.or(
new FindImports("com.vladmihalcea..*").getVisitor(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious as to the inclusion of com.vladmihalcea here, as it's the only reference to the package in this recipe/visitor. Since we include MigrateHypersistenceUtils61Types in src/main/resources/META-INF/rewrite/hibernate-6.yml after the ChangePackage from com.vladmihalcea to io.hypersistence.utils it should not be necessary to check for the old package if people run MigrateToHypersistenceUtilsHibernate6.0 or MigrateToHibernate61. Would you agree that we can then likely remove this check on com.vladmihalcea and simplify the precondition?

@timtebeek
Copy link
Contributor

Welcome back @iuliiasobolevska ! I've gone ahead an added a few additional commits to this one taking in some of the feedback above, as well as the parser classpath entry added in #8. There's now a small difference between the expected and actual output, using json.class in actual and lacking some annotations in expected. Would you want to work through those yourself?

@timtebeek timtebeek changed the title chore: [issue#4] add recipe for updating JSON type mapping with 'io.hypersistence:hypersistence-utils-hibernate' Update JSON type mapping with io.hypersistence:hypersistence-utils-hibernate Aug 17, 2023
@AlekSimpson AlekSimpson self-assigned this Sep 6, 2023
@timtebeek timtebeek self-requested a review June 11, 2024 17:21
timtebeek and others added 2 commits June 13, 2024 23:48
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…/issue-3-recipe-for-migrating-hypersistence-utils-types
github-actions[bot]

This comment was marked as outdated.

github-actions[bot]

This comment was marked as outdated.

@timtebeek timtebeek removed their request for review October 23, 2024 12:02
@timtebeek timtebeek marked this pull request as draft October 23, 2024 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request recipe
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

4 participants