persistence@glassfish.java.net

Re: Another cascade question

From: Markus Fuchs <Markus.Fuchs_at_Sun.COM>
Date: Sun, 12 Nov 2006 20:24:34 -0800
Hi Greg,

hard to tell. The mapping is correct. Could you post your test program here?

Thanks,

-- markus.

Greg Ederer wrote On 11/12/06 09:08,:
Hi,

Following Markus' excellent advice on my OneToOne cascade question, I subsequently created the following implementation:

CustomerNature has:

  @OneToMany(cascade={CascadeType.ALL}, mappedBy="customerNature")
  private List<CustomerOrder> customerOrders = new ArrayList<CustomerOrder>();

 
CustomerOrder has:

  @ManyToOne
  @JoinColumn(name="customer_nature", nullable=false)
  private CustomerNature customerNature;


When I run my tests, I get:

javax.persistence.RollbackException: Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2006.8 (Build 060830)): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: update or delete on "customer_nature" violates foreign key constraint "fk_customer_order_customernature_id" on "customer_order"
  Detail: Key (id)=(3) is still referenced from table "customer_order".Error Code: 0
Call:DELETE FROM customer_nature WHERE (ID = ?)
    bind => [3]


I am gradually working my way through the JSR 220 specification (wish I had more time to devote to this).  In the mean time, could some kind soul please enlighten me on this issue?

Thanks!

Greg
--
| E R G O N O S I S
| Greg Ederer
| Lead Developer
| greg@ergonosis.com
| 360.379.1157
| 
| OpenDocument - OK
|