Well, let's say I have a table of orders and items. This is how the elements in my Order class are described:
@ManyToMany(cascade=CascadeType.PERSIST) @JoinTable(name="MY_ORDER_ITEM_BRIDGE", joinColumns=@JoinColumn (name="bridge_order_id",referencedColumnName = "order_order_id"), inverseJoinColumns = @JoinColumn(name="bridge_item_id", referencedColumnName="item_item_id")) private List<Item> items;
It works great. But let the image, which is the date in the bridge table, be called MY_ORDER_ITEM_BRIDGE.expiration_date.
I want to change the definition to include only elements with expiration_date that have not yet occurred.
So I want the generated SQL to look something like this:
SELECT * FROM order o join my_order_item_bridge b on b.bridge_order_id = o.order_order_id join item i on i.item_item_id = b.bridge_item_id where b.expiration_date < sysdate;
I am using Ebean, Play Framework 2.1.3. Thanks for any help.
UPDATE : alternatively, this may also be the second condition for any of the connections:
SELECT * FROM order o join my_order_item_bridge b on b.bridge_order_id = o.order_order_id and b.expiration_date < sysdate join item i on i.item_item_id = b.bridge_item_id
(If possible, I would like to do this in a class definition not in raw SQL)
latj
source share