Seems that criteria.list() return exactly the same results for different parameters when caching enabled in some cases:
Repeatable call of this code with different parameter return exactly same results:
Code:
Criteria criteria = session.createCriteria(Operation.class);
criteria.setCacheable(true).setRegion("getFiltered#"+Operation.class.getName());
criteria.add(Restrictions.eq("doctype", doctype));
List r = criteria.list();
where doctype - instance of ObjectType:
Code:
@Entity
@Table(name = "OBJECT_TYPES", uniqueConstraints = {@UniqueConstraint(columnNames = {"name"})})
@Cache(usage = CacheConcurrencyStrategy.READ_ONLY, region = "ObjectType")
public class ObjectType implements Serializable{
@Id
@GeneratedValue
protected Long id;
....
}
It's work fine when caching disabled:
Code:
Criteria criteria = session.createCriteria(Operation.class);
criteria.add(Restrictions.eq("doctype", doctype));
List r = criteria.list();
Also, after many attempts, i found workaround for this:
Code:
Criteria criteria = session.createCriteria(Operation.class);
criteria.setCacheable(true).setRegion("getFiltered#"+Operation.class.getName());
criteria.add(Restrictions.eq("doctype.id", doctype.getId()));
List r = criteria.list();
Is it bug? Or some my lack of understanding?
Hibernate version:
hibernate 3.2.0.cr1
hibernate-annotation 3.1beta9
EHCache or JBoss TreeCache with OptimisticTreeCacheProvider
Stacktrace:
no stacke traces/silent
Name and version of the database you are using:
Oracle 10i