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