wood burning stoves 2.0*
The moose likes JPA Certification (OCEJPA) and the fly likes one query in 3 conditions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » JPA Certification (OCEJPA)
Bookmark "one query in 3 conditions" Watch "one query in 3 conditions" New topic
Author

one query in 3 conditions

sepand minoo
Greenhorn

Joined: Dec 25, 2012
Posts: 2

I have one table in database that contains 3 foreign keys to another tables(this three tables name are: manager,worker and employee). in each row only one foreign key is filled.I need to write one query that with attention which column of fk is filled in where clause specified condition is performed. I write simple query in jpa but doesn't work properly
select b from allEmployees b where b.manager.name= :name OR b.worker.name = :name OR b.employee.name= :name
do you have any idea?I have to resolve it but i don't have any idea
jagrutkumar dalwadi
Ranch Hand

Joined: Mar 26, 2009
Posts: 83

By looking at the query, it seems to be OK.
However can you please set setSqlEnabled property as true(in hibernate it is there, not sure about JPA) and check which query has been prepared by JPA?

Once you get simple query, you can fire on DB and check the expected behavior. If query is wrong, it means jpa query requires changes.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: one query in 3 conditions
 
Similar Threads
Criteria Issue
Get all Table names and count for foreign key
Composite foreign key mapping in Hibernate 3 using JPA
Can Foreign key be Null for some rows?
OneToMany Unidirectional strange behavior ?