Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB CMP:Issue in ejbRemove method  RSS feed

saivenkat venkatesan
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 in stateless session bean i am trying to find and delete the Customerorder entity bean.but it is trying to delete Customer entity i am getting constraint exception since in database these two tables are having forien key realationship.

Entitybean (Local)

Sateless session bean (Remote)

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 ]
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!