ObjectDB ObjectDB

Is named-query supported in orm.xml

#1

I prefer to keep custom JPQL named queries in an external file, e.g. orm.xml, rather than in the entity classes, for example:

  <named-query name= "DataValue.deleteByCapabilityAndCreationtime">
        <query>delete from DataValue d
                    where d.capabilityId = :capabilityId
                    and d.creationtime &lt;= :creationtime
        </query>
  </named-query>

This works fine with e.g. eclipseLink and postgres, but objectDB complains with an error like:

org.xml.sax.SAXParseException; lineNumber: 524; columnNumber: 70; cvc-complex-type.2.4.a: Invalid content was found starting with element 'named-query'. One of '{"http://java.sun.com/xml/ns/persistence/orm":entity, "http://java.sun.com/xml/ns/persistence/orm":embeddable}' is expected.

Does ObjectDB support externalised named queries, if so what's the recommended way to do it?

 

edit
delete
#2

It should be supported by ObjectDB. The error message indicates that the XML fails to pass validation against the JPA 2 ORM schema, probably because of the location of the named-query element in the XML file.

Maybe EclipseLink is more flexible and doesn't enforce the formal schema.

Global named queries should be defined in the XML before any type (entity, embeddable, etc.) definition. Named queries can also be defined in the XML of a specific entity after generator definition (if any) and before listener and attribute definitions.

ObjectDB Support
edit
delete
#3

yes, well spotted, many thanks ;-)

 

edit
delete

Reply

To post on this website please sign in.