"ReplaceSupportClassWithItsInterface" but interface is not yet (only after the migration) in classpath for Java visitor #4398
-
Hi OpenRewrite experts, during migration from Hibernate 5 to Hibernate 6 (plus Spring 2 to 3 and EE8 to EE10), we need to replace a Hibernate "final resulting SQL" interceptor
by this:
Obviously, the "org.openrewrite.java.spring.batch.ReplaceSupportClassWithItsInterface" would be a great candidate recipe to do this, but it won't work, and I am wondering whether I am assuming correctly that it's due to the following problem: Before migration, in the old Hibernate 5 world as seen by the Rewrite Java vistor, the new Hibernate 6-only target interface does not exist yet as a visitable class in the classpath (it is only provided with Hibernate 6). How would you recommend to resolve my specific issue? "Simply" using recipes based on regexp replacements afaik creates too many issues due to e.g. package import statements, but if possible, I'd like to avoid having to write a Java recipe... Many thanks for your feedback/opinions on this - much appreciated! 😄 👍 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
hi! We have an approach specifically for when you need more than one major version on the classpath for your recipes; That's also been integrated into rewrite-hibernate as you can see here and here. It sounds like the recipe you need would be a great addition there; and if you open a draft PR we'll gladly help you set up the steps you can't already work out using these hints. Let's continue on an issue or draft PR in rewrite-hibernate. :) |
Beta Was this translation helpful? Give feedback.
-
Hmm - great suggestion, unfortunately at this moment, due to pressing deadlines to get our full EE10/Spring 3/Hibernate 6 migration done, I won't have enough time to do it the fully correct and publicly reusable way, as this would indeed require more time to implement some medium complex Java recipe addition with the (great! 👏) "classpathFromResources" feature I hadn't been fully aware of before. I think I have a reasonably good idea of how this will have to be implemented, though, so once I have enough spare cycles (which won't be before mid-October unfortunately), I cannot promise, but am definitely tempted to get back to adding this (even though our own migration will likely be done by then!)... Sorry for being unable to provide something of general use right now under the present time pressure... 😢 |
Beta Was this translation helpful? Give feedback.
hi! We have an approach specifically for when you need more than one major version on the classpath for your recipes; That's also been integrated into rewrite-hibernate as you can see here and here. It sounds like the recipe you need would be a great addition there; and if you open a draft PR we'll gladly help you set up the steps you can't already work out using these hints. Let's continue on an issue or draft PR in rewrite-hibernate. :)