Reputation: 1513
class A {
def afterLoad() {
A.withTransaction {
}
}
}
Most case, it works, until I call below list in controller
A.createCriteria().list{.....}
will throw exception:org.hibernate.HibernateException: Found two representations of same collection
If I remove
A.withTransaction
It will then works.
Upvotes: 1
Views: 1412
Reputation: 6706
I've come across this exception myself and I was really stumped on it for a few days. You can see if the solution to this question solves your problem:
HibernateException: Found two representations of same collection
That solution didn't work for me, so I wrote an article describing the issue and what I did to solve it that you can read here. I believe your problem is similar to mine because of the transactional aspect, Hibernate is flushing the session when the transaction is committed and that's where the exception is thrown.
Upvotes: 0