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

add recipe for hibernate dialect update #44

Open
iuliiasobolevska opened this issue Nov 15, 2024 · 3 comments
Open

add recipe for hibernate dialect update #44

iuliiasobolevska opened this issue Nov 15, 2024 · 3 comments
Labels
good first issue Good for newcomers recipe

Comments

@iuliiasobolevska
Copy link
Contributor

What problem are you trying to solve?

Hibernate 6.2 dropped support for legacy database versions. As a result, legacy code corresponding to those versions was cleaned. One aspect of it is the clean up of org.hibernate.dialects.

What precondition(s) should be checked before applying this recipe?

Describe the situation before applying the recipe

spring:
  jpa:
    database-platform: org.hibernate.dialect.MySQL5Dialect
    properties:
      hibernate:
        dialect: org.hibernate.dialect.MySQL5Dialect

Describe the situation after applying the recipe

spring:
  jpa:
    database-platform: org.hibernate.dialect.MySQLDialect
    properties:
      hibernate:
        org.hibernate.dialect.MySQLDialect

Are you interested in [contributing this recipe to OpenRewrite]

This will look smth like:

type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.hibernate.MigrateToHibernateProperties6.2
displayName: Migrate to Hibernate 6.2 properties
description: Migrate properties found in `application.properties` and `application.yml` files.
recipeList:
  - org.openrewrite.properties.ChangePropertyValue:
      propertyKey: spring.jpa.database-platform
      newValue: org.hibernate.dialect.MySQLDialect
      oldValue: org.hibernate.dialect.MySQL5Dialect
  - org.openrewrite.properties.ChangePropertyValue:
      propertyKey: spring.jpa.properties.hibernate.dialect
      newValue: org.hibernate.dialect.MySQLDialect
      oldValue: org.hibernate.dialect.MySQL5Dialect

but needs to be extended to all removed dialects.

@timtebeek
Copy link
Contributor

Hi @iuliiasobolevska ; welcome back! @Laurens-W added some promising new work recently that mean we can now leverage ChangeType to also cover XML files already, and it seems that might be a good fit here as well, given that these properties refer to classes

That would then mean we don't have to repeat ourselves when it comes to replacing classes in Java files, XML files or YAML files. Do you have a link out to somewhere showing which dialects were replaced? That might help expand the list above already.

@iuliiasobolevska
Copy link
Contributor Author

iuliiasobolevska commented Nov 15, 2024

This problem is two-fold:

  • removed dialects that lead to runtime issues like Suppressed: java.lang.ClassNotFoundException: org.hibernate.dialect.MySQL5Dialect
  • deprecated dialects that are still there, e.g. org.hibernate.dialect.MySQL8Dialect

Do you have a link out to somewhere showing which dialects were replaced? That might help expand the list above already.

Several guides list supported dialects, e.g., https://docs.jboss.org/hibernate/orm/6.0/migration-guide/migration-guide.html#_dialects,Version-specific and spatial-specific dialects are deprecated section, but I don't see a list of the ones that were removed.

Ideally, the OpenRewrite recipe would match on \d+ and replace with counterpart without version.

@Laurens-W
Copy link
Contributor

Hey @iuliiasobolevska!

We'd require a SpringApplicationYaml equivalent of the SpringReference trait, which looking at it now isn't a very descriptive name as it only applies to Spring bean config XML's.
At that point the property key wouldn't matter, we can just treat them as types and replace them using ChangeType.

I could see if I can find the time to start a draft but I'm also curious what the user experience with this new Reference trait is like, would you be open to giving that a try?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers recipe
Projects
Status: Recipes Wanted
Development

No branches or pull requests

3 participants