Hi all,

In order to get the database constraints generated I haved added the
@ForeignKey annotation to the @ManyToOne  fields. In my application a user
edits an entry in a form which allows the user to select the foreign objects
from a list box which has been populated via a jpa query. So for example if
the object customer has a manytoone relationship to country the country drop
down allows selection of the country.

When trying to persist the customer object I get an error about the country
object already having an id value set and that this causes problems with
auto-generation. It appears that openjpa is attemtping to persist the
country object insead of just attaching it and seeing it is already in the
database. How can I fix this? I didn;t  have this problem when I wasn't
using @ForeignKey

thanks


-----
http://www.jumpingbean.co.za Jumping bean your java and linux experts 
http://www.cyberconnect.co.za Cyber Connect - More than just broadband 
-- 
View this message in context: 
http://www.nabble.com/Correct-way-to-use-%40ForeignKey--tp14545985p14545985.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to