Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB CMP:Issue in ejbRemove method  RSS feed

 
saivenkat venkatesan
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.


Entitybean (Local)
===========
CustomerBean.java
CustomerLocal.java
CustomerLocalHome.java

CustomerOrderBean.java
CustomerOrderLocal.java
CustomerOrderLocalHome.java

Sateless session bean (Remote)
=====================
ShoppingCartSession.java
ShoppingCartSessionBean.java
ShoppingCartSessionHome.java



This is what i am doing

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 sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!