I am new to EJB CMP-CMR relationship. I have two entity bean Customer and CustomerOrder with one to many realtionship.Also in the database i have the two tables Customer and CustomerOrder with customerId is a forienkey in CustomerOrder table. I am able to insert customer and corresponding customerorders into database tables. I want to delete some of the customer's order from CustomerOrder table.so in stateless session bean i am trying to find and delete the Customerorder entity bean.but it is trying to delete Customer entity bean.so i am getting constraint exception since in database these two tables are having forien key realationship.
1) In ShoppingCartSessionBean I lookup the Customer and CustomerOrder. 2) Using customerId,found the Customer bean(cHome.findByPrimaryKey(custId)) 3) Fetch all the orders of this customer( Collection orders = customerLocal.getCustomerOrder() 4) trying to delete particular order by primary key ( customerOrderLocalHome.remove(CustomerOrderKey))
5) I am getting the below error message
Caused by: java.sql.SQLException: [IBM][SQLServer JDBC Driver][SQLServer]DELETE statement conflicted with COLUMN REFERENCE constraint 'FK_CustomerOrder_Customer'. The conflict occurred in database 'Shooping', table 'CustomerOrder', column 'customerId'
How to delete an entity bean in CMP ?
Please help me where i am doing mistake.Why it is trying to delete parent table ? [ July 13, 2007: Message edited by: saivenkat venkatesan ]
It is no measure of health to be well adjusted to a profoundly sick society. -Krishnamurti Tiny ad:
how do I do my own kindle-like thing - without amazon