Francisco Sousa (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5e949f3...
) *commented* on HHH-15951 (
https://hibernate.atlassian.net/browse/HHH-15951?atlOrigin=eyJpIjoiMzdjOG...
)
Re: Hibernate 6 Error : Already registered a copy:
SqmBasicValuedSimplePath(fullyqualifiedclass.name) (
https://hibernate.atlassian.net/browse/HHH-15951?atlOrigin=eyJpIjoiMzdjOG...
)
I had a similar situation.
After some days debugging the Hibernate’s code, I found the problem.
In my case, I was providing the same instance of Path for more then one instance of
Predicate. In other words I had two instances of Predicate , but both had the same
internal instance of Path.
It was happening because I am using Specification with JPARepository , and I was doing a
paginated query, so JPA do two queries, one to get the result list, and a count query to
get the total rows.
Thus, the method toPredicate of my spec was being called two times, once for list and once
for count, but in my spec implementation I was reusing "root.get(myprop)".
Something like this:
public class MySpec<MyEntity> implements Specification<MyEntity> {
private Path<Y> path;
...
@Override
public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query,
CriteriaBuilder builder) {
if (path == null ) {
path = root.get( "myprod" );
}
return builder.equal(path, "myvalue" );
}
...
}
On each call to toPredicate , a new predicate is created by builder.equal , but in my
case, the Path was the same and it was causing the trouble.
Anyway, I hope this can help someone.
(
https://hibernate.atlassian.net/browse/HHH-15951#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-15951#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100214- sha1:3d33cb1 )