• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

EJB CMP:Issue in ejbRemove method

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic