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
Default accessors on projection interfaces must not be considered input properties [DATACMNS-967] #1423
Comments
Oliver Drotbohm commented Can you please share a bit more code? The rough outline of the domain type that's about to be projected, the repository query method you're trying to use this with. The exception suggests your |
Sebastian Staudt commented That's right, public class Person {
@Column(name = "given_name")
private String givenName;
@Id
@Column(name = "login")
private String login;
@Column(name = "sur_name")
private String surName;
public String getFullName() {
return String.format("%s, %s", this.surName, this.givenName);
}
public String getGivenName() {
return this.givenName;
}
public void setGivenName(String givenName) {
this.givenName = givenName;
}
public String getLogin() {
return this.login;
}
public void setLogin(String login) {
this.login = login;
}
public String getSurName() {
return this.surName;
}
public void setSurName(String surName) {
this.surName = surName;
}
} |
Oliver Drotbohm commented What does the repository method look like? From the stack trace you seem to be trying to query on that attribute, which — as you just stated — doesn't really make sense then |
Sebastian Staudt commented An example repository method that's failing looks like this: List<ContactPersonProjection> findTop10OrderByNameAsc(); |
Oliver Drotbohm commented Ah okay, it looks like we're trying to derive a path ( Thanks for the quick feedback! |
Oliver Drotbohm commented Oh, I just realized. You should be able to workaround that issue by just moving away from the property syntax for the method name: |
Oliver Drotbohm commented Binaries with fixes available. Feel free to give them a spin. Proper tests only on 2.0.x unfortunately as we can't declare default methods in 1.x branches due to JDK 6 compatibility requirement |
Sebastian Staudt commented The workaround works, but I stumbled upon another issue as closed projections seem to generate broken HQL queries for entity subclasses. Where can I get the binaries for testing the fix? |
Oliver Drotbohm commented Just use our snapshot repository and point to |
Sebastian Staudt commented The fix works. Tested with 1.12.7.BUILD-SNAPSHOT |
Sebastian Staudt opened DATACMNS-967 and commented
Recently, I tried to transform my projection interfaces into closed projections to optimize database queries. Before, I used
@Value
annotations aka. open projections in various places:I thought that Java 8's default method implementations might be a good way to workaround this limitation. My new projection looks like this:
But it seems the query lookup strategy tries to create queries for the default methods, too.
It would be great to have this working out of the box.
PS: Default methods work like expected on open projections (e.g. when there's already one
@Value
method present)Affects: 1.13 RC1 (Ingalls), 2.0 M1 (Kay), 1.12.6 (Hopper SR6)
Referenced from: commits 9137dc7, c31714c, a946d65
Backported to: 1.13 GA (Ingalls), 1.12.7 (Hopper SR7)
The text was updated successfully, but these errors were encountered: