Steven Nakhla wrote:
> LicenseKey:  properties=keyValue (String)
> Vendor:  properties=name (String)
> Product properties=title (String), version (String)
> 
> These beans all have CMRs setup as well.  The relations are as
> follows: 
> 
> Vendor (1) -> Product (Many)
> Product (1) -> LicenseKey (Many)
> 
> I would like to create a finder method that allows me to locate a
> Product based on the LicenseKey entered.  Can someone give me an
> example of how this might be accomplished?

The EJB-QL may depend on the Product-LicenseKey relation directionality.
Starting with the assumption that you denoted it with your arrow --
Product has a unidirectional one-to-many relation to LicenseKey with the
accessor "public abstract Collection getLicenseKeys() -- here's the
signature and EQL:

    your.package.ProductLocal findByLicenseKeyValue(java.lang.String
licenseKeyValue)
    SELECT OBJECT(p) FROM Product p, IN(p.licenseKeys) l WHERE
l.keyValue = ?1

If the relation is unidirectional the other way (LicenseKey to Product),
you'll use something like this (All of my relationships are either
bi-1:N or uni-1:N, so I haven't tried this):

    SELECT OBJECT(p) FROM Product p WHERE p.licenseKey.keyValue = ?1

If it's bidirectional, take your pick.

> I've poked around on
> Google for EJB-QL examples, but can't seem to find something that
> fits.  I'd appreciate any help you could give.  Thanks!    

I used www.ejb-ql.com, but it seems to be down now. :( Here's an OnJava
article on EJB-QL (first page is all XML descriptor tags):
http://www.onjava.com/pub/a/onjava/2001/09/19/ejbql.html. The second
page, however, showed me the correct syntax for the second EQL above.
Oh, be careful as I just found a syntax error in one of their examples
(I think):

    SELECT OBJECT (o) FROM Order AS o IN (o.lineItems) li
    WHERE li.quantity = ?1

This needs a "," ("Order As o, IN ...") or so the examples earlier on
the page show. Anyway, if you find more good references, please add to
the thread.

David Harkness
Sr. Software Engineer
Sony Pictures Digital Networks
(310) 482-4756


-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

Reply via email to