-->
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.  [ 5 posts ] 
Author Message
 Post subject: Queries very slow in a transaction
PostPosted: Tue Mar 06, 2007 2:53 pm 
Newbie

Joined: Thu Jun 22, 2006 12:11 am
Posts: 14
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?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 06, 2007 3:04 pm 
Newbie

Joined: Tue Dec 12, 2006 2:07 pm
Posts: 8
Are you doing a

Code:
session.commit()


?

-----------------------
Don't forget to rate!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 06, 2007 3:07 pm 
Newbie

Joined: Tue Dec 12, 2006 2:07 pm
Posts: 8
Are you doing a

Code:
session.commit()


?

-----------------------
Don't forget to rate!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 06, 2007 3:32 pm 
Newbie

Joined: Thu Jun 22, 2006 12:11 am
Posts: 14
gah Ive fixed it now, I was doing silly things

cheers


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 06, 2007 6:53 pm 
Newbie

Joined: Thu Jun 22, 2006 12:11 am
Posts: 14
bah, no its still mung

Ive found that I am using Hibernate.intialise() on alot of entities (1000+) because I close the session off once they are all loaded, but the more entities I intialise within a transaction, the slow querying gets, I assume this is some sort of by product of having so many entities intialised, and hibernate handling that..

any help would be much appreciated.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.