This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

EJB CMP:Issue in ejbRemove method  RSS feed

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