Hi Tony, Absolutely, annotations and xml definitions can be mixed in the same application. Per the spec, the xml definitions rule over the annotations. This makes sense -- you would want your deployment packaging (xml definitions) overrule the annotations that your developers insert into the code.
Kevin On Thu, Mar 18, 2010 at 9:01 AM, Tony McLay <[email protected]> wrote: > Hello, > > Can entities be defined as annotations in a class and in a <mapping-file> > referenced from a persistence.xml file? (or must you use one or other > technique?) > We are using openjpa 1.2.1 > > We have an application where entities have been defined using class > annotations. However, we have run into a problem where we need to use > nvarchar types for mssql (multibyte support), and this can be solved by > creating persistence units defined in a persistence.xml file - these units > in turn reference the required entities defined in a <mapping-file> - then > we use a columnDefinition attribute to define the type for mssql. > Currently, we have just put one entity into the mapping file, and left the > other entity definitions as class annotations, but for a many-to-one > element defined in the mapping file entity, the table generated does not > add a foreign key constraint (that maps to another entity defined as a > class annotation). > > I want to check if I can avoid putting all the entities in the mapping > file (bit of a slog) - is this a know issue - I've tried every permutation > of attributes/elements in the many-to-one element in the xml mapping-file, > but cannot get a foreign key generated (just generates as a basic column). > > Thanks > Tony > > > > > > Unless stated otherwise above: > IBM United Kingdom Limited - Registered in England and Wales with number > 741598. > Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU > > > > > >
