Hi that worked fine, except I hav to change the version attribute to 1.0
Cheers, Håkon On 14 September 2010 16:56, Rick Curtis <[email protected]> wrote: > Hakon - > > > ... it's possible to specify the named queries in a separate file, and > still define the entities using annotations? > Yes, you can specify mapping information in annotations and via mapping > file(s). In the case where mapping information is specified in both > annotations and xml, the xml mapping information will always take > precedence. > > For example, if you wanted to use the orm.xml file for only your named > queries, you could do something along these lines (borrowed from our unit > test bucket)... > > <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation=" > http://java.sun.com/xml/ns/persistence/ormorm_2_0.xsd" > version="2.0"> > <entity name="XMLFieldAccess2" > class="org.apache.openjpa.persistence.access.xml.XMLFieldAccess2"> > <named-query name="XMLFieldAccess2.query"> > <query>SELECT xfa FROM XMLFieldAccess2 xfa WHERE xfa.id = :id > AND xfa.strField = :strVal </query> > </named-query> > </entity> > </entity-mappings> > > This information can be put in a couple different places. The easiest is to > put it in META-INF/orm.xml. Another option is to create another xml file > and > you'll need to specify > <mapping-file>org/apache/openjpa/persistence/xml/orm.xml</mapping-file> in > your persistence.xml. If you follow one of these two options correctly, the > enhancer will find the mapping file(orm.xml) and instrument your Entities > correctly. > > > Are there any guides on how to work with orm files using openjpa(?) > Unfortunately I haven't found much good information, even the spec is > pretty > light on mapping using the orm.xml. Maybe someone else on the list has some > input? One good place to look for examples is the openjpa unit tests. We > have a pretty exhaustive test suite that should help get you going. > > Thanks, > Rick > > 2010/9/14 Håkon Sagehaug <[email protected]> > > > Hi all, > > > > Up til now I created my entities using the java annotations with queries > > etc, but was wondering if it's possible to specify the named queries in a > > separate file, and still define the entities using annotations. Or do I > > have > > to do my entities in orm file if I want the named queries in XML or > > similar. > > > > Are there any guides on how to work with orm files using openjpa, does > the > > enhancer create the needed java classes from the XML or how does it work? > > > > Cheers, Håkon > > >
