hi guys
i'm using hibernate for only a few days and now i'm a bit stuck with the following.
when i query for all rows of a class than and the caching is enabled (i'm using ehcache) than hibernate requeries everytime all rows individally:
Hibernate: select ort0_.id as id12_0_, ort0_.version as version12_0_, ort0_.lastUpdatedBy as lastUpda3_12_0_, ort0_.lastUpdated as lastUpda4_12_0_, ort0_.plz as plz12_0_, ort0_.name as name12_0_ from Ort ort0_ where ort0_.id=?
Hibernate: select ort0_.id as id12_0_, ort0_.version as version12_0_, ort0_.lastUpdatedBy as lastUpda3_12_0_, ort0_.lastUpdated as lastUpda4_12_0_, ort0_.plz as plz12_0_, ort0_.name as name12_0_ from Ort ort0_ where ort0_.id=?
Hibernate: select ort0_.id as id12_0_, ort0_.version as version12_0_, ort0_.lastUpdatedBy as lastUpda3_12_0_, ort0_.lastUpdated as lastUpda4_12_0_, ort0_.plz as plz12_0_, ort0_.name as name12_0_ from Ort ort0_ where ort0_.id=?
Hibernate: select ort0_.id as id12_0_, ort0_.version as version12_0_, ort0_.lastUpdatedBy as lastUpda3_12_0_, ort0_.lastUpdated as lastUpda4_12_0_, ort0_.plz as plz12_0_, ort0_.name as name12_0_ from Ort ort0_ where ort0_.id=?
Hibernate: select ort0_.id as id12_0_, ort0_.version as version12_0_, ort0_.lastUpdatedBy as lastUpda3_12_0_, ort0_.lastUpdated as lastUpda4_12_0_, ort0_.plz as plz12_0_, ort0_.name as name12_0_ from Ort ort0_ where ort0_.id=?
my query code:
Code:
Session s = openSession();
try {
Criteria criteria = s.createCriteria(Ort.class).setCacheable(true).setCacheRegion("ort");
return criteria.list();
} finally {
s.close();
}
my very simple class
Code:
@Entity(access = AccessType.FIELD)
public class Ort extends BaseEntity {
@Id(generate = GeneratorType.AUTO)
private Long id;
@Basic
@Column(nullable = false)
private int plz;
@Basic
@Column(nullable = false)
private String name;
...
i've just noticed that when i requery it after a long while only a single select is performed - which is much quicker...
what do i do wrong?
many thanks for any feedback in advance!
fabian