Tuesday, 27 August 2013

How to define a where clause in a onetomany class definition

How to define a where clause in a onetomany class definition

I am new to Java Persistence etc I have a one to many relation defined and
it works, but I cannot define the where clause in the many entity. For
instance, my search is returning a list of orders and a collection of
order items per order. But, how do I apply a where clause in the LineItem
entity class e.g. The native SQL will look like this (roughly)
SELECT Orders.OrderNumber, LineItems.Quantity, LineItems.Description
FROM Orders, LineItems WHERE Orders.OrderID = LineItems.OrderID
AND LineItems.Description IN ('XXX1', 'XXXXX2','XXXX3')`
AND LineItems.Quantity = 5
I dont know how to define the :
AND LineItems.Description IN ('XXX1', 'XXXXX2','XXXX3')
AND LineItems.Quantity = 5
in the LineItems class. Please Help.

No comments:

Post a Comment