I get this warning (HibernateException: Found shared references to a collection
), but SOMETIMES, not always, as in other threads. Another interesting thing is that I'm only performing SELECT on db, no inserts at all, nowhere in my whole project.
My DB structure is dead simple:
====== ===========
user criteria
------ -----------
id -----> user_id
name id
... keywords
====== ...
===========
my method looks like this:
private synchronized ArrayList<AutomailingCriteria> getUserCriteria(Integer uid){
this.session.beginTransaction();
Query query = this.session.createQuery("from AutomailingCriteria where user.id = :uid");
query.setParameter("uid", uid);
ArrayList<AutomailingCriteria> result = new ArrayList<>(query.list());
if(!this.session.getTransaction().wasCommitted()){
this.session.getTransaction().commit();
}
return result;
}
and is being called synchronously by 4 threads.