-->
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: How to avoid cross join from hibernate generated sql
PostPosted: Mon Oct 01, 2012 1:55 pm 
Newbie

Joined: Thu Mar 25, 2010 11:58 am
Posts: 4
Hi,

I am trying to execute a HQL query

Code:
SELECT COUNT(V.id) FROM Vendor as V LEFT JOIN V.vendorType as VT WHERE V.activeInd='Y'


Hibernate generates the following query

Code:
select 
    count(vendor0_.ID) as col_0_0_   
    from 
    OPDS.VENDOR vendor0_, 
    OPDS.VENDOR_TYPE vendortype1_ cross   
    join 
    OPDS.VENDOR vendor2_   
    where 
    vendor0_.VENDOR_TYPE_ID=vendortype1_.ID(+)   
    and vendor0_.VENDOR_ID=vendor2_.ID   
    and vendor0_.ACTIVE_IND='Y'   


that causes the error in oracle : ORA-25156: old style outer join (+) cannot be used with ANSI joins

Please suggest a solution for this. I don't know why hibernate generates a cross join automatically.

Code:
class Vendor{ 
        @ManyToOne(fetch = FetchType.LAZY) 
        @JoinColumn(name = "VENDOR_TYPE_ID") 
        public VendorType getVendorType() { 
            return this.vendorType; 
        } 
     
        public void setVendorType(VendorType vendorType) { 
            this.vendorType = vendorType; 
        } 
    } 


Code:
class VendorType{ 
        @OneToMany(fetch = FetchType.LAZY, mappedBy = "vendorType") 
        public Set<Vendor> getVendors() { 
            return this.vendors; 
        } 
     
        public void setVendors(Set<Vendor> vendors) { 
            this.vendors = vendors; 
        } 
    } 


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.