persistence@glassfish.java.net

Re: Embedded objects in EJBQL

From: Tom Ware <tom.ware_at_oracle.com>
Date: Thu, 19 Jan 2006 13:12:33 -0500

Hi Michael,

  Thanks for the information. We will await what the specification has
to say about these things.

  There is a bug in our internal bug system tracking an issue that gets
in the way of the 2nd issue you mention. We are currently not dealing
with the parameters that are instances of an Embeddable correctly. We
can investigate more if the specification begins to allow this.

-Tom

Michael Bouschen wrote:

>Hi Tom,
>
>I looked at using embedded objects in EJBQL. I tried a couple of EJBQL
>queries navigating through an embedded object and they all work, e.g.
>- SELECT c FROM Customer c WHERE c.embeddedCountry.code = 'de'
>- SELECT c.embeddedCountry.code FROM Customer c
>- SELECT c.embeddedCountry.code FROM Customer c
> GROUP BY c.embeddedCountry.code
>
>Here are the results of using embedded where it is currently not
>supported in EJBQL:
>
>(1) Selecting an embedded object
> SELECT c.embeddedCountry FROM Customer c
>This runs into a QueryException Invalid query item expression [Query Key
>embeddedCountry Base ejbql.models.Customer] thrown from
>ReportItem.initialize(ReportItem.java:110)
>
>(2) Comparing an embedded object with a parameter.
> SELECT c FROM Customer c WHERE c.embeddedCountry = :country
>The generated SQL uses the toString of the embedded when comparing the
>columns for the embedded:
> SELECT ID, ... FROM CUSTOMER_TABLE
> WHERE ((COUNTRY_CODE = 'ejbql.models.EmbeddedCountry_at_14e3f41') AND
> (COUNTRY_NAME = 'ejbql.models.EmbeddedCountry_at_14e3f41'))
>
>Regards Michael
>
>

-- 
Tom Ware
Principal Software Engineer
Oracle Canada Inc.
Direct: (613) 783-4598
Email: tom.ware_at_oracle.com