openrewrite / rewrite-hibernate

OpenRewrite recipes for Hibernate ORM.
Apache License 2.0
4 stars 7 forks source link

Compilation error: 'package org.hibernate.criterion does not exist' after using Hibernate recipe for 6.x #30

Open mathewm3 opened 4 weeks ago

mathewm3 commented 4 weeks ago

What version of OpenRewrite are you using?

I am using

How are you running OpenRewrite?

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

            <plugin>
                <groupId>org.openrewrite.maven</groupId>
                <artifactId>rewrite-maven-plugin</artifactId>
                <version>5.35.0</version>
                <configuration>
                    <activeRecipes>
                        <recipe>org.openrewrite.hibernate.MigrateToHibernate62</recipe>
                    </activeRecipes>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.openrewrite.recipe</groupId>
                        <artifactId>rewrite-hibernate</artifactId>
                        <version>1.8.0</version>
                    </dependency>
                </dependencies>
            </plugin>

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

import org.hibernate.criterion.Criterion;

What did you expect to see?

the package org.hibernate.criterion.* is removed from hibernate 6. 

No modification was made. The removed packages should be deleted and replacement code should available. https://github.com/hibernate/hibernate-orm/blob/6.0/migration-guide.adoc#legacy-hibernate-criteria-api

What did you see instead?

import org.hibernate.criterion.Criterion;

pom.xml changes were done

            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>5.6.15.Final</version>

changed to

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

pom.xml file changes from 5.6.15.Final to 6.2.28.Final

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

NA

Are you interested in contributing a fix to OpenRewrite?

NA

timtebeek commented 4 weeks ago

Hi @mathewm3 ; when you say "the replacement code should available", could you give an example? I haven't used Hibernate in a while, and the link you gave only says

The legacy Hibernate Criteria API which was deprecated back in Hibernate 5.x and removed in 6.0. Usually, all queries using the legacy API can be modeled with the JPA Criteria API. In some cases it is necessary to use the Hibernate JPA Criteria extensions.

I notice you've logged this as a bug, whereas we have a slightly different template that might help recipe development for recipe requests: https://github.com/openrewrite/rewrite-hibernate/issues/new?assignees=&labels=recipe&projects=&template=recipe_request.md&title=

If you could provide such before/after examples then we'd be in a better shape to suggest how to develop such a recipe.