This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » JPA Certification (OCEJPA)
Bookmark "one query in 3 conditions" Watch "one query in 3 conditions" New topic

one query in 3 conditions

sepand minoo

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 :name OR = :name OR :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.
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 ?