-
Notifications
You must be signed in to change notification settings - Fork 7
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
Migrate UserType
implementations to hibernate 6
#40
Conversation
src/test/java/org/openrewrite/hibernate/MigrateUserTypeTest.java
Outdated
Show resolved
Hide resolved
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
src/test/java/org/openrewrite/hibernate/MigrateUserTypeTest.java
Outdated
Show resolved
Hide resolved
@Nullable | ||
private static J.FieldAccess parameterizedType = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mutable static fields in a recipe are not ideal; can we move this field into the visitor instead? As each call the getVisitor
returns a new isolated instance, whereas the Recipe
instance can be shared.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Nullable | |
private static J.FieldAccess parameterizedType = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should check if we have any legitimate cases of this. If not, we can add a best practice recipe, maybe?
Co-authored-by: Tim te Beek <[email protected]>
Order methodmatchers alphabetically
src/test/java/org/openrewrite/hibernate/MigrateUserTypeTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/hibernate/MigrateUserTypeTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions could not be made:
- src/main/java/org/openrewrite/hibernate/EmptyInterceptorToInterface.java
- lines 28-29
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions could not be made:
- src/main/java/org/openrewrite/hibernate/EmptyInterceptorToInterface.java
- lines 28-28
- src/main/java/org/openrewrite/hibernate/ReplaceLazyCollectionAnnotation.java
- lines 29-29
private static final MethodMatcher REPLACE = new MethodMatcher("* replace(java.lang.Object, java.lang.Object, java.lang.Object)"); | ||
private static final MethodMatcher RESULT_SET_STRING_PARAM = new MethodMatcher("java.sql.ResultSet *(java.lang.String)"); | ||
private static final MethodMatcher RETURNED_CLASS = new MethodMatcher("* returnedClass()"); | ||
private static final MethodMatcher SQL_TYPES = new MethodMatcher("* sqlTypes()"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we equally use org.hibernate.usertype.UserType
here instead of *
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way I'm using them to match method declarations it seems you can only really use a wildcard pattern or the type of the enclosing J.ClassDeclaration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions could not be made:
- src/main/java/org/openrewrite/hibernate/EmptyInterceptorToInterface.java
- lines 28-28
- src/main/java/org/openrewrite/hibernate/ReplaceLazyCollectionAnnotation.java
- lines 29-29
return maybeAutoFormat(method, md, ctx); | ||
} | ||
|
||
private J.MethodDeclaration changeParameterTypes(J.MethodDeclaration md, List<String> paramNames) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Matching on parameter names isn't safe here, as folks might have named their variables differently; I suggest you change this to use the parameter index instead, or another way of ensuring only the correct types are changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied parameter index instead of name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The paramNames
variable isn't safe; let's change that first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to see! I've applied some simplifications and best practices; let's see how this holds up against older code bases. 🤞🏻
Anything in particular you'd like reviewers to focus on?
Test coverage
Anyone you would like to review specifically?
@timtebeek
Any additional context
https://docs.jboss.org/hibernate/orm/5.6/javadocs/org/hibernate/usertype/UserType.html
https://docs.jboss.org/hibernate/orm/6.0/javadocs/org/hibernate/usertype/UserType.html
Checklist