persistence@glassfish.java.net

Re: Cascade Join query involving collection attributes

From: Farrukh Najmi <farrukh_at_wellfleetsoftware.com>
Date: Mon, 31 Mar 2008 16:15:59 -0400

I think I have figured it out as follows:

SELECT OBJECT(thing1) from
    Thing thing1 LEFT OUTER JOIN thing1.name.localizedString name_ls,
    Thing thing2 LEFT OUTER JOIN thing2.description.localizedString desc_ls
    WHERE
    (thing1.id = thing2.id) AND    
    ((:name = '%') OR (UPPER(name_ls.value) LIKE UPPER(:name)))
    AND ((:description = '%') OR (UPPER(desc_ls.value) LIKE UPPER(:description)))

Let me know if there is a better way. Thanks.

Farrukh Najmi wrote:
Dear Colleagues,

This is probably a very simple question but I am having trouble coming up with the correct query.

The Object Model for Entity classes looks as follows.

ObjectModel for Entity Classes


I am trying to determine a parameterized query that will match all things that have a name and description that match specified pattern using :name and :description
query parameters. I want to make sure that if a Thing has 0 Name (or Description) then if :name (or :description is '%') then the Thing should match the query.

I am not exactly sure how to deal with the fact that we have to navigate thru multiple levels of collection attributes for each of the following:
Also I am not sure how to cope with the possibility that:
Any help on this query would be greatly appreciated. Thanks.
-- 
Regards,
Farrukh Najmi

Web: http://www.wellfleetsoftware.com

  


-- 
Regards,
Farrukh Najmi

Web: http://www.wellfleetsoftware.com


picture
(image/gif attachment: 01-part)