Java Mailing List Archive

http://www.gg3721.com/

Home » users.openjpa »

Can Class annotations and xml definitions be mixed in the same application
- problem with many-to-one foreign key generation

Tony McLay

2010-03-18

Replies: Find Java Web Hosting

Author LoginPost Reply
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





©2008 gg3721.com - Jax Systems, LLC, U.S.A.