-
Notifications
You must be signed in to change notification settings - Fork 101
Add default constructor to Entity class #415
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 default constructor to Entity class #415
Conversation
src/main/java/org/openrewrite/java/migrate/javax/AddDefaultConstructorToEntityClass.java
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/javaee/AddDefaultConstructorToEntityClassTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/javaee/AddDefaultConstructorToEntityClassTest.java
Outdated
Show resolved
Hide resolved
…nstructorToEntityClassTest.java Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…structorToEntityClass.java Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
src/test/java/org/openrewrite/java/migrate/javaee/AddDefaultConstructorToEntityClassTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/javaee/AddDefaultConstructorToEntityClassTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/javaee/AddDefaultConstructorToEntityClassTest.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/javax/AddDefaultConstructorToEntityClass.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/javax/AddDefaultConstructorToEntityClass.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/javax/AddDefaultConstructorToEntityClass.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/javax/AddDefaultConstructorToEntityClass.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/javax/AddDefaultConstructorToEntityClass.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/javax/AddDefaultConstructorToEntityClass.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.
Great work once again! Good to see you worked out the issue with context sensitivity when injecting a constructor. Indeed that'll be down to how we generate and extract the code snippet from JavaTemplate. If you're ever curious what gets generated you can add this little snippet to the code to get the generated template.
class __P__ {
static native <T> T p();
static native <T> T[] arrp();
static native boolean booleanp();
static native byte bytep();
static native char charp();
static native double doublep();
static native int intp();
static native long longp();
static native short shortp();
static native float floatp();
}
class __M__ {
static native Object any(Object o);
static native Object any(java.util.function.Predicate<Boolean> o);
static native <T> Object anyT();
}
public class MissingNoArgConstructorEntity {
private int id;
public MissingNoArgConstructorEntity(int id) {
}
/*__TEMPLATE__*/
public MissingNoArgConstructorEntity() {
}/*__TEMPLATE_STOP__*/
}
For constructors specifically we need that context sensitivity, as otherwise the generated template does not compile.
Hope that helps you on your next one!
Once again we'll wait for @cjobinabo to merge when convenient there! :) |
src/main/java/org/openrewrite/java/migrate/javax/AddDefaultConstructorToEntityClass.java
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/javax/AddDefaultConstructorToEntityClassTest.java
Show resolved
Hide resolved
src/main/java/org/openrewrite/java/migrate/javax/AddDefaultConstructorToEntityClass.java
Outdated
Show resolved
Hide resolved
Reverted recent change because |
What's changed?
New recipe for OpenJPA -> EclipseLink migration
If class is tagged with
@Entity
or@MappedSuperclass
, add default no-arg constructor if missing.What's your motivation?
https://wiki.eclipse.org/EclipseLink/Examples/JPA/Migration/OpenJPA/Mappings#No-arg_Constructor
Checklist