-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: why is hibernate requerying for every single row?
PostPosted: Thu Dec 29, 2005 8:21 am 
Newbie

Joined: Thu Dec 29, 2005 7:35 am
Posts: 5
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


Top
 Profile  
 
 Post subject: Re: why is hibernate requerying for every single row?
PostPosted: Thu Dec 29, 2005 8:27 am 
Newbie

Joined: Thu Dec 29, 2005 7:35 am
Posts: 5
ah, i forgot to add the following to the class definition...

Code:
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)


problem solved.

cheers
fabian


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.