-->
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: Ok.. I've lost it...or not? (performace prob)
PostPosted: Thu Oct 02, 2003 5:25 am 
Beginner
Beginner

Joined: Thu Oct 02, 2003 5:06 am
Posts: 26
Location: Budapest, Hungary
Either I'm doing something wrong.. or I'm doing something wrong.

here's the picture. I have an InvoiceItem table and an Invoice table, parent-child relationship.. no problem yet.
In the InvoiceItem I have 6 many-to-one connections (via IDs) to other tables (Objects), and in Invoice I also have several.

Code:
<class name="com.tibbett.controlling.hibernate.Invoice" table="invoice">
                <id name="invoiceID" column="invoiceid" type="long" unsaved-value="null">
                        <generator class="sequence">
                            <param name="sequence">invoice_uid_sequence</param>
                        </generator>
                </id>

                <property name="sysdocNumber" column="sysdocnumber" length="10" type="string"/>
                <property name="sysdocDate" column="sysdocdate" length="4" type="date"/>
                <property name="recordDate" column="recorddate" length="4" type="date"/>
                <property name="bookingDate" column="bookingdate" length="4" type="date"/>
                <property name="period" column="period" length="4" type="integer"/>
                <property name="cancelled" column="cancelled" length="1" type="boolean"/>
                <property name="estimate" column="estimate" length="1" type="boolean"/>
               
                <many-to-one name="type" class="com.tibbett.controlling.hibernate.Type" column="typeid"/>
                <many-to-one name="currency" class="com.tibbett.controlling.hibernate.Currency" column="currencyid"/>
                <many-to-one name="supplier" class="com.tibbett.controlling.hibernate.Supplier" column="supplierid"/>
                <many-to-one name="cancelledInvoice" class="com.tibbett.controlling.hibernate.Invoice" column="cancelled_invoiceid"/>
                <many-to-one name="legalEntity" class="com.tibbett.controlling.hibernate.LegalEntity" column="legalentityid"/>
                <many-to-one name="pillangoPeriod" class="com.tibbett.controlling.hibernate.PillangoPeriod" column="pillangoperiodid"/>
                                                               
                <set name="invoiceItems" cascade="all" inverse="true" lazy="true">
                        <key column="invoiceid"/>
                        <one-to-many class="com.tibbett.controlling.hibernate.InvoiceItem"/>
                </set>                               
        </class>

and
Code:
<class name="com.tibbett.controlling.hibernate.InvoiceItem" table="invoiceitem">
                <id name="itemID" column="itemid" type="long" unsaved-value="null">
                        <generator class="sequence">
                            <param name="sequence">invoiceitem_uid_sequence</param>
                        </generator>
                </id>
               
                <property name="text3" column="text3" length="255" type="string"/>
                <property name="heading" column="heading" length="255" type="string"/>
                <property name="reference" column="reference" length="20" type="string"/>
                <property name="internalOrder" column="internalorder" length="255" type="string"/>
                <property name="amount" column="amount" length="8" type="double"/>
                <property name="amountOc" column="amountoc" length="8" type="double"/>
                <property name="cancelled" column="cancelled" length="1" type="boolean"/>
                <property name="estimate" column="estimate" length="1" type="boolean"/>
                <property name="allocationLevel" column="allocationlevel" length="1" type="integer"/>
                <property name="finalLevel" column="final" length="1" type="boolean"/>
<-- some of these also have many-to-one relations to other classes -->
                <many-to-one name="profitcenter" class="com.tibbett.controlling.hibernate.Profitcenter" column="profitcenterid"/>                 
                <many-to-one name="costcenter" class="com.tibbett.controlling.hibernate.Costcenter" column="costcenterid"/>                   
                <many-to-one name="ledger" class="com.tibbett.controlling.hibernate.Ledger" column="ledgerid"/>                   
                <many-to-one name="invoice" class="com.tibbett.controlling.hibernate.Invoice" column="invoiceid"/>                   
                <many-to-one name="pillangoPeriod" class="com.tibbett.controlling.hibernate.PillangoPeriod" column="pillangoperiodid"/>
                <many-to-one name="allocationParent" class="com.tibbett.controlling.hibernate.InvoiceItem" column="allocation_parentid"/>
             
                <set name="allocationChildren" cascade="all" inverse="true" lazy="true">
                        <key column="allocationParent"/>
                        <one-to-many class="com.tibbett.controlling.hibernate.InvoiceItem"/>
                </set>           
        </class>


all works fine, util I need to do a query along the lines of
Code:
from  InvoiceItem item
                    where item.pillangoPeriod.pillangoPeriodID=? and
                    item.profitcenter.allocatable=true and item.allocationLevel=0 and
                    item.cancelled = false and item.finalLevel=true


It takes about 80 seconds to return 1200 rows. I assume its going off and initializing pretty much my entire database here and draggin all the objects along with it, since if I only
Code:
select item.itemID

using the same where conditions, it returns in just under 0.8 sec. So the actual search is fine, it chokes when initalizing the objects (I tried getting the IDs first and then loading them.. same thing, the load causes the long delay).

all I can say is.. HELP! anyone have suggestions? I REALLY don't want to go back and hardcode SQL queries for this.. it'll get nasty, and require a huge change in our whole approach to the project.

Yes.. we are hibernate newbies.. this is out first project using it, and so far .. well.. wow :-)
please.. if anyone has suggestions/guidelines/ideas? (I've searched the forum and ..although I may be blind .. haven't found references to this type of problem - are we missing something realy simple here???)

cheers
Ati
email: ati dot rosselet at clarmont dot hu


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 02, 2003 5:52 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Enable proxies on all the classes that are referenced by <many-to-one> associations in Item.


Top
 Profile  
 
 Post subject: hmm... proxy.. that looks good.
PostPosted: Thu Oct 02, 2003 6:51 am 
Beginner
Beginner

Joined: Thu Oct 02, 2003 5:06 am
Posts: 26
Location: Budapest, Hungary
Thanks for the incredibly quick response..
If I understand correctly this will just stop those objects from being initalized/loaded.

Sorry.. stream of thought writing here. I guess that means I need to make a new bean to put together HTML output for the servlet, since the session will be closed if I just return the selected items to the servlet.

otherwise.. lazy instantiation errors galore..

If I returned these 'truncated' objects to a servlet/application, how can I then get a complete object w/sub objects? session.load(object,id) and then reference it? (eg. item.getInvoice().getSupplier().getSupplierCode() ?) Or will this again generate the same type of overhead I was getting before?

Tnx again.
Ati


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 02, 2003 7:34 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
check out the HQL "FETCH" clause.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 02, 2003 9:39 am 
Beginner
Beginner

Joined: Thu Oct 02, 2003 5:06 am
Posts: 26
Location: Budapest, Hungary
ok... hmm..
does everything have to have a proxy, or only worthwhile for those classes that have associations (many-to-one)?

The select has now improved from 65sec for 1148 records to 5secs...
but that still seems a bit steep. -> 67000 records in 150 secs? :(

I'm now doing:
Code:
elect item from InvoiceItem item inner join fetch item.invoice


where everyone and their dog has a proxy.
what effect does the outer-join section of a many-to-one mapping actually have? If all connections will be pretty much inner joins.. would it help to set this to false?
Tnx.[/code]


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.