Giter VIP home page Giter VIP logo

rewrite-hibernate's People

Contributors

boykoalex avatar iuliiasobolevska avatar jkschneider avatar kunli2 avatar mike-solomon avatar mikomatic avatar sambsnyd avatar shanman190 avatar simonverhoeven avatar simonzn avatar timtebeek avatar tkvangorder avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

rewrite-hibernate's Issues

`TypeAnnotationParameter` should remove `@Type(type = "org.hibernate.type.TextType")`

Hi the Hibernate 6.1 uprev recipe https://docs.openrewrite.org/recipes/hibernate/typeannotationparameter|TypeAnnotationParameter seems to produce invalid code as part of a Spring Boot 3.2 uprev, given the following input source snippet:

@Type(type = "org.hibernate.type.TextType")
private String description;

produces:

import org.hibernate.type.TextType;
...
  @Type(TextType.class)
  private String description;

There is no such class TextType in Hib 6.1. I think in this case the correct action would be just to remove the @Type annotation completely.

Slack Message

Recipe to replace @Type(type = "true_false")

What problem are you trying to solve?

With Hibernate 5 we could map booleans to "T" / "F" by using the "true_false" usertype. Hibernate 6 no longer supports that, but offers an attribute converter as replacement.

Describe the situation before applying the recipe

class A {
    @Type(type = "true_false")
    boolean isSomething() {
        return isSomething;
    }
}

Describe the situation after applying the recipe

class A {
    @Convert(converter = TrueFalseConverter.class)
    boolean isSomething() {
        return isSomething;
    }
}

Are you interested in contributing this recipe to OpenRewrite?

I have implemented a working recipe. PR is coming up.

Recipe for migration of @LazyCollection annotation

What problem are you trying to solve?

@LazyCollection is deprecated since Hibernate 6.2 and we should use jakarta.persistence.FetchType instead.

Any additional context

LazyCollectionOption.EXTRA cannot be directly mapped to FetchType. I don't know if automated migration is feasible in that case.

Are you interested in contributing this recipe to OpenRewrite

I have implemented a recipe that works well in our project and will open a pull request as a starting point. Please point out all problems and misusages of your API :-)

Boolean used to be @Type mappable, but now requires conversion (when migrating from hibernate 5 to 6)

What version of OpenRewrite are you using?

I am using

  • OpenRewrite v8.14.0
  • Maven/Gradle plugin v5.22.0
  • rewrite-hibernate v1.1.5

How are you running OpenRewrite?

I am using the Maven plugin, and my project is a single module project.

mvn org.openrewrite.maven:rewrite-maven-plugin:5.22.0:run -Drewrite.activeRecipes=redacted -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-spring:5.4.0,org.openrewrite.recipe:rewrite-static-analysis:1.3.0 -Drewrite.exclusions=**api**.yaml

What is the smallest, simplest way to reproduce the problem?

@Entity
class A {
  @Type(type = "boolean")
  private Boolean isAllowed;
}

What did you expect to see?

@Entity
class A {
  @Convert(converter = org.hibernate.type.NumericBooleanConverter.class)
  private Boolean isAllowed;
}

What did you see instead?

@Entity
class A {
  @Type(boolean.class)
  private Boolean isAllowed;
}

What is the full stack trace of any errors you encountered?

It's not necessarily an issue with openrewrite, more that the code left after the recipe ran is non compiling. I think the NumericConverter matches previous behaviour.

Are you interested in contributing a fix to OpenRewrite?

Add a recipe to migrate to Hypersistence for Hibernate 6.3

What problem are you trying to solve?

There is an existing recipe to migrate to Hibernate 6.2.

This migration handles migration of the dependency io.hypersistence:hypersistence-utils-hibernate-60 to io.hypersistence:hypersistence-utils-hibernate-62

In order to migrate to Hibernate 6.3, a new recipe could handle the migration from io.hypersistence:hypersistence-utils-hibernate-62 to io.hypersistence:hypersistence-utils-hibernate-63, (see installation guide )

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

This migration should probably depend on org.openrewrite.hibernate.MigrateToHibernate62

Describe the situation before applying the recipe

<?xml version="1.0" encoding="UTF-8"?>
<project
	xmlns="http://maven.apache.org/POM/4.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.example</groupId>
	<artifactId>demo</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<dependencies>
		<dependency>
			<groupId>io.hypersistence</groupId>
			<artifactId>hypersistence-utils-hibernate-62</artifactId>
			<version>3.7.3</version>
		</dependency>
	</dependencies>
</project>

Describe the situation after applying the recipe

<?xml version="1.0" encoding="UTF-8"?>
<project
	xmlns="http://maven.apache.org/POM/4.0.0"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.example</groupId>
	<artifactId>demo</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<dependencies>
		<dependency>
			<groupId>io.hypersistence</groupId>
			<artifactId>hypersistence-utils-hibernate-63</artifactId>
			<version>3.7.3</version>
		</dependency>
	</dependencies>
</project>

Have you considered any alternatives or workarounds?

No

Any additional context

This recipe could later be used in the org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_2 recipe

Are you interested in contributing this recipe to OpenRewrite?

Yes, i could do a PR if that is Ok, this seems like a simple recipe that relies only on org.openrewrite.java.dependencies.ChangeDependency

Recipe to migrate the use of Ehcache 2.0 to 3.0 in Hibernate

Hibernate has deprecated the use of the ehcache 2.0 in favor of using jcache (with the ehcache 3.0 as the underlying implementation)

This recipe should:

  • Replace hibernate-ehcache dependency with hibernate-jcache
  • It should replace the hibernate.cache.region.factory_class property with jcache
  • It should add the following two properties :
<property name="hibernate.javax.cache.provider" value="org.ehcache.jsr107.EhcacheCachingProvider"/>
<property name="hibernate.javax.cache.uri" value="file:/META-INF/ehcache.xml"/>

And finally if the ehcache.xml file does not exist, it should create that file with a defaultCache entry:

<ehcache>
    <defaultCache maxEntriesLocalHeap="1000" eternal="false" timeToIdleSeconds="300" timeToLiveSeconds="600">
    </defaultCache>
</ehcache>

Property in depdencyManagement of parent pom not changed, version tag added in submodul pom

I just ran the following command:

mvn org.openrewrite.maven:rewrite-maven-plugin:run -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-hibernate:RELEASE -Drewrite.activeRecipes=org.openrewrite.hibernate.MigrateToHibernateDependencies61

The project on which I applied it has a parent-pom and multiple submodule-poms. The parent-pom has a dependencyManagement section where versions are defined using properties. The submodules only list the dependencies without version declaration.

This was before open rewrite:
parent pom:

<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-core</artifactId>
  <version>${hibernate.version}</version>
</dependency>

submodul pom:

<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-core</artifactId>
</dependency>

This after:
parent pom:

<dependency>
  <groupId>org.hibernate.orm</groupId>
  <artifactId>hibernate-core</artifactId>
  <version>6.1.0.Final</version>
</dependency>

submodul pom:

<dependency>
  <groupId>org.hibernate.orm</groupId>
  <artifactId>hibernate-core</artifactId>			
  <version>6.1.0.Final</version>
</dependency>

OpenRewrite replaced the property in the parent pom (instead of changing it) and added a version tag to the submodul pom although it isnt necessary there

Add a new recipe to migrate to io.hypersistence:hypersistence-utils-hibernate:6 types

What problem are you trying to solve?

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

Should use io.hypersistence:hypersistence-utils-hibernate-60 or io.hypersistence:hypersistence-utils-hibernate-62.
Note: I logged a separate issue for package group changes: #4 since that one is trivial to do and requires fewer things to be considered.

Describe the situation before applying the recipe

From https://github.com/vladmihalcea/hypersistence-utils#hibernate-5:

@Type(type = "json")
private Map<String, String> properties = new HashMap<>();

Describe the situation after applying the recipe

From https://github.com/vladmihalcea/hypersistence-utils#hibernate-6:

@Type(JsonType.class)
private Map<String, String> properties = new HashMap<>();

Any additional context

We used to also apply

@TypeDefs({@TypeDef(name = "json", typeClass = JsonStringType.class)})

at the class level. If I read migration guide correctly these annotations should be removed by the recipe.

Extend org.openrewrite.java.migrate.hibernate.MigrateToHibernateDependencies61 recipe to change dependency group for hibernate-types

What problem are you trying to solve?

vladmihalcea/hypersistence-utils was relocated from com.vladmihalcea group to io.hypersistence. When customers migrate from Hibernate 5 to 6, they need to update dependency to use a new group and version.

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

From the migration guide:

  • for Hibernate 6.0 and 6.1, the recipe should use io.hypersistence:hypersistence-utils-hibernate-60:3.4.1,
  • for Hibernate 6.2 - io.hypersistence:hypersistence-utils-hibernate-62:3.4.1.

Describe the situation before applying the recipe

implementation 'com.vladmihalcea:hibernate-types-52:2.17.1'

Describe the situation after applying the recipe

implementation 'io.hypersistence:hypersistence-utils-hibernate-60:3.4.1'

Are you interested in contributing this recipe to OpenRewrite?

Can contribute the week of June 12th-16th '23.
Would you prefer a new recipe or adding it to the existing org.openrewrite.java.migrate.hibernate.MigrateToHibernateDependencies61 recipe?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.