I have two classes Customer (1 <----> 1) CreditCard.
// works fine
Code:
Customer c = new Customer(..);
CreditCard cr = new CreditCard(..);
c.setCard(cr);
cr.setCustomer(c);
session.store(c);
// does not work Afterwards If i want to set new Card for the customer
Code:
Customer c = findCustomerById(...);
CreditCard card = new CreditCard(...);
c.setCard(card);
card.setCustomer(c);
session.store(c);
there is a exception that
java.sql.BatchUpdateException: Invalid argument value, message from server: "Duplicate entry '1' for key 1"
xml Mapping for corresponding elements..
card to customer
<one-to-one
name="customer"
class="rrr.titan.entity.Customer"
cascade="all"
/>
customer to card
<one-to-one
name="creditCard"
class="rrr.titan.entity.CreditCard"
cascade="all"
outer-join="auto"
constrained="false"
/>
I tried modifying generator class for CreditCard id to
foriegn it did not solve the problem.
My Question is how to update 1 <----> 1 relations ?