persistence@glassfish.java.net

Re: Embedded objects in EJBQL

From: Michael Bouschen <Michael.Bouschen_at_Sun.COM>
Date: Fri, 20 Jan 2006 12:59:48 +0100

Hi Tom,

Mike replied that the spec will not add any extra support for embeddeds,
so navigation through it is the only thing you can do with an embedded.
Since navigation is working, I marked the corresponding glassfish issue
as fixed: https://glassfish.dev.java.net/issues/show_bug.cgi?id=51

Regards Michael

> 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
>>
>>
>