Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.2.1.GA
Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<class
name="nzs.common.server.entitySupport.entities.Cntl"
table="CNTL"
discriminator-value="0"
batch-size="10"
>
<meta attribute="implement-equals" inherit="false">true</meta>
<id
name="key"
type="java.lang.String"
column="KEY"
>
<generator class="assigned" />
</id>
<discriminator insert="false" type ="int" formula="0"/>
<!-- Properties -->
<property
name="numValue"
type="java.math.BigDecimal"
column="NUM_VALUE"
length="17"
>
<meta attribute="use-in-tostring">true</meta>
<meta attribute="use-in-equals">true</meta>
</property>
<property
name="alphaValue"
type="java.lang.String"
column="ALPHA_VALUE"
length="256"
>
<meta attribute="use-in-tostring">true</meta>
<meta attribute="use-in-equals">true</meta>
</property>
<property
name="dateTime"
type="java.util.Date"
column="DATETIME"
length="7"
>
<meta attribute="use-in-tostring">true</meta>
<meta attribute="use-in-equals">true</meta>
</property>
<property
name="des"
type="java.lang.String"
column="DES"
length="255"
>
<meta attribute="use-in-tostring">true</meta>
<meta attribute="use-in-equals">true</meta>
</property>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close(): Query q1 = session.createQuery("from Cntl cntl where cntl.key = 'BW_EUSR'");
long s1 = System.currentTimeMillis();
q1.list();
System.out.println("s1 = " + ( System.currentTimeMillis() - s1 ));
session.beginTransaction();
Query q2 = session.createQuery("from Cntl cntl where cntl.key = 'BW_EUSR'");
long s2 = System.currentTimeMillis();
q2.list();
System.out.println("s2 = " + ( System.currentTimeMillis() - s2 ));
Name and version of the database you are using:Oracle9i Enterprise Edition Release 9.2.0.4.0
The generated SQL (show_sql=true):Code:
Hibernate:
/*
from
Cntl cntl
where
cntl.key = 'BW_EUSR' */
select
cntl0_.KEY as KEY9_,
cntl0_.NUM_VALUE as NUM2_9_,
cntl0_.ALPHA_VALUE as ALPHA3_9_,
cntl0_.DATETIME as DATETIME9_,
cntl0_.DES as DES9_,
0 as clazz_
from
CNTL cntl0_
where
cntl0_.KEY='BW_EUSR'
Debug level Hibernate log excerpt:
s1 = 0
s2 = 1938
Now when I run the query prior to opening the transaction it runs nice and quick as you'd expect (being a simple select) but afterwards, its takes close to 2 seconds to do the exact same thing...
Am I missing something or doing something wrong?