Hi All!
I'm using OpenJPA (Strategy: XMLValueHandler) + JAXB to store XML documents.
I have an XML document which looks something like this (JAXB):
<patientType>
<firstName/>
<lastName/>
<sex/>
<!-- and so on... ->
<!-- now, complexType -->
<address>
<city/>
<!-- street, postalCode, country etc -->
</address>
</patientType>
I can execute basic queries in JPA + JAXB for example:
select object(o) from ErsPatient as o where o.patientinfo.lastName =
:lastName and o.patientinfo.sex = :sex
patientinfo is XML column, and it works fine.
But if I want to access address element's children I get errors, for example:
select object(o) from ErsPatient as o where o.patientinfo.lastName =
:lastName and o.patientinfo.sex = :sex and
o.patientinfo.address.country = :country
I get:
Exception in thread "main" <openjpa-1.0.1-r420667:592145 nonfatal user
error> org.apache.openjpa.persistence.ArgumentException: An error
occurred while parsing the query filter "select object(o) from
ErsPatient as o where o.patientinfo.lastName = :lastName and
o.patientinfo.sex = :sex and o.patientinfo.address.country =
:country". Error message: No field named "country" in class "class
org.xh.business.AddressType".
at
org.apache.openjpa.kernel.exps.AbstractExpressionBuilder.parseException(AbstractExpressionBuilder.java:118)
at
org.apache.openjpa.kernel.exps.AbstractExpressionBuilder.traverseXPath(AbstractExpressionBuilder.java:252)
at
org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getPath(JPQLExpressionBuilder.java:1303)
at
org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getPathOrConstant(JPQLExpressionBuilder.java:1261)
at
org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.eval(JPQLExpressionBuilder.java:859)
kill me but there is country field in AddressType class...
of course I tried with other fields, but JPA does not see them.
Only the direct children (firstName, sex, etc) of root <patientType>
can be accessed.
Am I missing something, or is it OpenJPA?
any ideas?
best regards
Łukasz