-->
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: Query Cache not working
PostPosted: Mon Oct 09, 2006 12:13 pm 
Newbie

Joined: Thu Apr 29, 2004 10:22 am
Posts: 5
Location: Ribeir
Hibernate version:
3.1.3

Mapping documents:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
  <class table="activation" name="pragya.usc.activation.Activation">
    <cache usage="read-write"/>
    <id name="id">
      <generator class="identity"/>
    </id>
    <property name="startDate" not-null="false" column="initialdatetime"/>
    <property name="endDate" not-null="false" column="finaldatetime"/>
    <property name="ani" not-null="false" length="30"/>
    <property name="dnis" not-null="false" length="30"/>
    <property name="enable" not-null="false" column="isenable"/>
    <many-to-one column="id_voicemenu" lazy="proxy" name="voiceMenu"/>
    <many-to-one column="fk_portal" lazy="proxy" name="portal"/>
    <property name="promptPath" not-null="false" length="200" column="path_prompt"/>
    <property name="serviceId" not-null="false" column="id_service"/>
    <property name="templateId" not-null="false" column="id_template"/>
    <property name="accessType" not-null="false" length="20" column="type_access"/>
    <property name="vxmlPath" not-null="false" length="200" column="path_vxml"/>
    <many-to-one column="id_childportal" lazy="proxy" name="childPortal"/>
    <property name="permissionServiceId" column="fk_id_permissionservice"/>
    <joined-subclass name="com.pragya.usc.activation.business.ActivationSMS" table="activationsms">
      <key column="fk_id_activation"/>
      <map table="activationsms_keyword" lazy="false" inverse="false" sort="natural" cascade="all-delete-orphan" name="keywords">
        <cache usage="read-write"/>
        <key column="fk_id_activation"/>
        <map-key type="string" formula="keyword"/>
        <element type="string" column="keyword"/>
      </map>
    </joined-subclass>
  </class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

First query:
Code:
      Query query = session.createQuery("from Activation activation where activation.class = Activation");
      query.setCacheable(true);
      List activation = query.list();


Second query:
Code:
      Query query = session
            .createQuery("from Activation activation where activation.class = Activation and ? between activation.startDate and activation.endDate and activation.enable = ? ");
      query.setTimestamp(0, date);
      query.setBoolean(1, enable);
      query.setCacheable(true);

      List activations = query.list();

Name and version of the database you are using:
PostgreSQL 8.0.4

The generated SQL (show_sql=true):

First query:
Code:
select activation0_.id as id16_, activation0_.initialdatetime as initiald2_16_, activation0_.finaldatetime as finaldat3_16_, activation0_.ani as ani16_, activation0_.dnis as dnis16_, activation0_.isenable as isenable16_, activation0_.id_voicemenu as id7_16_, activation0_.fk_portal as fk8_16_, activation0_.path_prompt as path9_16_, activation0_.id_service as id10_16_, activation0_.id_template as id11_16_, activation0_.type_access as type12_16_, activation0_.path_vxml as path13_16_, activation0_.id_childportal as id14_16_, activation0_.fk_id_permissionservice as fk15_16_, case when activation0_1_.fk_id_activation is not null then 1 when activation0_.id is not null then 0 end as clazz_ from activation activation0_ left outer join activationsms activation0_1_ on activation0_.id=activation0_1_.fk_id_activation where case when activation0_1_.fk_id_activation is not null then 1 when activation0_.id is not null then 0 end=0


Second query:
Code:
select activation0_.id as id16_, activation0_.initialdatetime as initiald2_16_, activation0_.finaldatetime as finaldat3_16_, activation0_.ani as ani16_, activation0_.dnis as dnis16_, activation0_.isenable as isenable16_, activation0_.id_voicemenu as id7_16_, activation0_.fk_portal as fk8_16_, activation0_.path_prompt as path9_16_, activation0_.id_service as id10_16_, activation0_.id_template as id11_16_, activation0_.type_access as type12_16_, activation0_.path_vxml as path13_16_, activation0_.id_childportal as id14_16_, activation0_.fk_id_permissionservice as fk15_16_, case when activation0_1_.fk_id_activation is not null then 1 when activation0_.id is not null then 0 end as clazz_ from activation activation0_ left outer join activationsms activation0_1_ on activation0_.id=activation0_1_.fk_id_activation where case when activation0_1_.fk_id_activation is not null then 1 when activation0_.id is not null then 0 end=0 and (? between activation0_.initialdatetime and activation0_.finaldatetime) and activation0_.isenable=?



Hi guys,

I have an issue with this queries. The first one is cached at the first and it wasn't call in the laters calls. But the second query no cache the resultset and is called always. Am I missing something?

I want the two queries to be cached...

regards,
Flavio Suguimoto


Top
 Profile  
 
 Post subject: Query Cache not working
PostPosted: Tue Oct 10, 2006 7:36 am 
Newbie

Joined: Thu Apr 29, 2004 10:22 am
Posts: 5
Location: Ribeir
After some tests and changes... Now i guess that this issue occurs because some problems with joined-subclass and cache. All my queries and classes are cached without setCacheable, just the first query of my last post need it to use cache. But, the others queries with some kind of filter don't work, even that i use setCacheable(true).

Could anyone help me?


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.