Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Databases
»
Object Relational Mapping
Author
How to avoid cross join from hibernate generated sql
Robo Fazak
Greenhorn
Joined: Mar 25, 2010
Posts: 8
posted
Oct 01, 2012 11:28:23
0
Hi,
I am trying to execute a HQL query
SELECT COUNT(V.id) FROM Vendor as V LEFT JOIN V.vendorType as VT WHERE V.activeInd='Y'
Hibernate generates the following query
select count(vendor0_.ID) as col_0_0_ from OPDS.VENDOR vendor0_, OPDS.VENDOR_TYPE vendortype1_ cross join OPDS.VENDOR_LU 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.
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; } @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "VENDOR_ID", nullable = false) @NotNull public VendorLu getVendorLu() { return this.vendorLu; } public void setVendorLu(VendorLu vendorLu) { this.vendorLu = vendorLu; } }
class VendorType{ @OneToMany(fetch = FetchType.LAZY, mappedBy = "vendorType") public Set<Vendor> getVendors() { return this.vendors; } public void setVendors(Set<Vendor> vendors) { this.vendors = vendors; } }
class VendorLu{ @OneToMany(fetch = FetchType.LAZY, mappedBy = "vendorLu") public Set<Vendor> getVendors() { return this.vendors; } public void setVendors(Set<Vendor> vendors) { this.vendors = vendors; } }
SCJP 1.6
Bill Gorder
Bartender
Joined: Mar 07, 2010
Posts: 1282
I like...
posted
Oct 02, 2012 17:22:22
0
There is more than one Oracle Dialect are you using the correct one?
http://docs.jboss.org/hibernate/orm/3.5/api/org/hibernate/dialect/package-summary.html
Are you using the correct
JDBC
driver for Oracle? What version of Oracle and Hibernate are you using?
[
How To Ask Questions
][
Read before you PM me
]
I agree. Here's the link:
http://zeroturnaround.com/jrebel
- it saves me about five hours per week
subject: How to avoid cross join from hibernate generated sql
Similar Threads
@ManyToMany and Select query
Problem with Hibernate Criteria, Projections and associations
Going crazy.. can't join on this compound key class and not sure why?
eager fetching of lazy formulas via criteria api
EJB QL w/ ManyToMany
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter