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.  [ 1 post ] 
Author Message
 Post subject: equals() is being called lot of time Performance Bottelneck
PostPosted: Tue Oct 11, 2005 7:48 am 
Newbie

Joined: Tue Aug 09, 2005 9:34 am
Posts: 5
Hi All ,
I am using Hibernate 3.0 . I am facing performance problem with hibernate. I used JProbe to find the performnace bottelneck . After analyzing JProbe report , i found InvoiceChargePK.equals() method is called millons of time and time spent on it is the major one.

Basically it is something like this; I need to load say the data with the following primary keys. (note that prior to this some other queries are also executed as part of the transaction; I am using HibernateTemplate.find)
Key1 Key 2
101 1
101 2
101 3
102 1

Now when i call the find with 101, 1 the .equals method is called once with 101, 1; The second time around, it gets called twice with 101, 1 and 101,2, and so on and so forth. So if i had to load 1500 key combinations. I end up with 1.12 million calls to PK.equals.

The mapping files are :-

InvoiceBillingDevice -------------

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

<hibernate-mapping package="qc.qbid.invoice.model.bo">
<class
name="InvoiceBillingDevice"
table="INVOICE_BILLING_DEVICE"
>

<id
name="invoiceBillingDeviceId"
column="INVOICE_BILLING_DEVICE_ID"
type="integer"

>
<generator class="increment"/>
</id>

<many-to-one
name="invoice"
column="INVOICE_ID"
class = "qc.qbid.invoice.model.bo.Invoice"
/>

</class>
</hibernate-mapping>


InvoiceCharge :-------------
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping package="qc.qbid.invoice.model.bo">
<class
name="InvoiceCharge"
table="INVOICE_CHARGE" >
<composite-id name="invoiceChargeId" class="InvoiceChargePK">
<key-many-to-one
name="invoiceBillingDevice"
class="qc.qbid.invoice.model.bo.InvoiceBillingDevice"
column="INVOICE_BILLING_DEVICE_ID"
/>
<key-many-to-one
name="chargeType"
class="qc.qbid.admin.model.bo.ChargeType"
column="CHARGE_TYPE_ID"
/>
</composite-id>
</class>
</hibernate-mapping>

InvoicePayment:-------------

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

<hibernate-mapping package="qc.qbid.invoice.model.bo">
<class
name="InvoicePayment"
table="INVOICE_PAYMENT" >
<id
name="invoicePaymentId"
type="integer"
column="INVOICE_PAYMENT_ID"
>
<generator class="increment"/>
</id>
<property
name="invoiceBillingDeviceId"
column="INVOICE_BILLING_DEVICE_ID"
type="integer"
not-null="false"
insert= "false"
update="false"
/>

<property
name="chargeTypeId"
column="CHARGE_TYPE_ID"
type="long"
not-null="false"
insert= "false"
update="false"
/>
<many-to-one
name="invoiceCharge"
class="InvoiceCharge"
lazy="true"

>
<column name = "INVOICE_BILLING_DEVICE_ID"/>
<column name = "CHARGE_TYPE_ID"/>
</many-to-one>

<many-to-one
name="invoiceBatch"
column="INVOICE_BATCH_ID"
class="InvoiceBatch"
not-null="true"

>
</many-to-one>

</class>
</hibernate-mapping>

InvoiceBatch :-----------
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping package="qc.qbid.invoice.model.bo">
<class
name="InvoiceBatch"
table="INVOICE_BATCH"
>
<id
name="invoiceBatchId"
type="integer"
column="INVOICE_BATCH_ID"
>
<generator class="increment"/>
</id>
<many-to-one
name="invoice"
column="INVOICE_ID"
class="Invoice"
not-null="true"
>
</many-to-one>
<many-to-one
name="batchStatus"
column="STATUS_ID"
class="BatchStatus"
not-null="true"
>
</many-to-one>


</class>
</hibernate-mapping>


The query is :---

final List invoicePaymentList = this.getHibernateTemplate().find("select invoicePayment " +
" from InvoicePayment invoicePayment where " +
" invoicePayment.invoiceBatch = " +
invoiceBatch.getInvoiceBatchId() +
" and invoicePayment.invoiceCharge.invoiceChargeId.invoiceBillingDevice = " +
invoiceBillingDevice.getInvoiceBillingDeviceId() +
" and invoicePayment.invoiceCharge.invoiceChargeId.chargeType = " +
chargeType.getChargeTypeId());


If this method is clalled n times , the no of calls to InvoiceChargePK.equals() is [n*(n-1)/2] .

Looking for any inputs
Thanks in advance
Vaibhav


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.