I had a method in ProjectRepository that looked something like this:
findByUserID(int userID);
This will be a list of all projects that link to a specific user. Due to other requirements, I now need to refer to the user from the project, and not just the user ID, for example:
@ManyToOne
@JoinColumn(name = "userID", referencedColumnName = "userID")
private User user;
Which was usually:
int userID;
So, I replaced the method:
findByUser(User user);
But this requires an additional call to the database to get the User object for this user ID. Is there a way to use the first method for my new class? If I just save the first method, I get
org.springframework.data.mapping.PropertyReferenceException: No property ID found for type User! Traversed path: Project.user.
Is this possible without writing a custom request?
source
share