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: redundand joins in generated sql
PostPosted: Fri Jun 17, 2005 5:54 am 
Newbie

Joined: Tue May 17, 2005 8:39 am
Posts: 14
Hi

I have written Hibernate Criteria that searches in table Transactions.
Why Hibernate has genereted SQL query with all those joins that are completely redundand ?

Hibernate version:

2.1

Code between sessionFactory.openSession() and session.close():
Code:
Criteria criteria = session.createCriteria(Transaction.class)
                .add(Expression.le("statusRefreshTime", systemDate))
                .add(Expression.in("txStatus",new Byte[] {new Byte (TransactionGatewayConstants.TX_STATUS_UNKNOWN),new Byte (TransactionGatewayConstants.TX_STATUS_PENDING)} ));
           
            List transactions = criteria.list();

            return transactions;


Name and version of the database you are using:

MySQL 4.1

The generated SQL (show_sql=true):

select this.transactionId as transact1_6_, this.bankTransactionId as bankTran2_6_, this.amount as amount6_, this.description as descript4_6_, this.errorCode as errorCode6_, this.created as created6_, this.chargebackFee as chargeba7_6_, this.txStatus as txStatus6_, this.tx3DsecureStatus as tx3Dsecu9_6_, this.statusRefreshTime as statusR10_6_, this.customerName as custome11_6_, this.customerEmail as custome12_6_, this.customerIP as customerIP6_, this.orderId as orderId6_, this.referenceId as referen15_6_, this.reverseReason as reverse16_6_, this.reverseDate as reverse17_6_, this.chargeback as chargeback6_, this.chargebackDate as chargeb19_6_, this.merchantNotification as merchan20_6_, this.accountId as accountId6_, this.bankId as bankId6_, this.merchantId as merchantId6_, this.currencyId as currencyId6_, account1_.accountId as accountId0_, account1_.site as site0_, account1_.merchantNotificationUrl as merchant3_0_, account1_.chargebackFee as chargeba4_0_, account1_.accountLimit as accountL5_0_, account1_.merchantId as merchantId0_, account1_.currencyId as currencyId0_, merchant2_.merchantId as merchantId1_, merchant2_.name as name1_, merchant2_.description as descript3_1_, merchant2_.passwd as passwd1_, currency3_.currencyId as currencyId2_, currency3_.description as descript2_2_, bank4_.bankId as bankId3_, bank4_.name as name3_, bank4_.description as descript3_3_, bank4_.bankLimit as bankLimit3_, bank4_.serverUrl as serverUrl3_, merchant5_.merchantId as merchantId4_, merchant5_.name as name4_, merchant5_.description as descript3_4_, merchant5_.passwd as passwd4_, currency6_.currencyId as currencyId5_, currency6_.description as descript2_5_ from transactions this left outer join accounts account1_ on this.accountId=account1_.accountId left outer join merchants merchant2_ on account1_.merchantId=merchant2_.merchantId left outer join currencies currency3_ on account1_.currencyId=currency3_.currencyId left outer join banks bank4_ on this.bankId=bank4_.bankId left outer join merchants merchant5_ on this.merchantId=merchant5_.merchantId left outer join currencies currency6_ on this.currencyId=currency6_.currencyId where this.statusRefreshTime<=? and this.txStatus in (?, ?)


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.