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