aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Problem with CMR Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Problem with CMR " Watch "Problem with CMR " New topic
Author

Problem with CMR

priya pillai
Ranch Hand

Joined: Sep 12, 2007
Posts: 57
Hi friends,


I am doing small project with eclipse,weblogic,and doing ejb using XDoclet


In my order_header table my primary key is po_no

In my order_detail table my primary key is serial_no and FK is po_no

orderheader bean cmr relations are given as



/**

*

*

* <!-- begin-user-doc -->

* CMR Field items

*

* Returns the items

* @return the items

*

* <!-- end-user-doc -->

*

* <!-- begin-xdoclet-definition -->

* @ejb.interface-method

* view-type="local"

*

* @ejb.relation

*

* name="OrderDetail"

* role-name="Order-contains-Items"

* target-ejb="OrderDetail"

* target-role-name="item-contained-in-order"

* target-cascade-delete="yes"

*

* @weblogic.target-column-map

* foreign-key-column="po_no"

* key-column="po_no"

*

*

*

*

* <!-- end-xdoclet-definition -->

* @generated

*/

public abstract java.util.Collection getItems();

/**

* <!-- begin-user-doc -->

* Sets the Items

*

* @param java.util.Collection the new items value

* <!-- end-user-doc -->

*

* <!-- begin-xdoclet-definition -->

* @ejb.interface-method

* view-type="local"

* <!-- end-xdoclet-definition -->

* @generated

*/

public abstract void setItems(java.util.Collection items);





I am getting the error of



Error: in testing pagejava.rmi.RemoteException: EJB Exception: ; nested exception is: javax.ejb.TransactionRolledbackLocalException: EJB Exception: ; nested exception is: weblogic.utils.NestedRuntimeException: Error writing from beforeCompletion - with nested exception: [java.sql.SQLException: Cannot add or update a child row: a foreign key constraint fails]

I think prob is with cmr relation.....Can you help me....
Shailesh Kini
Ranch Hand

Joined: Oct 17, 2001
Posts: 153
Hello Priya,

Do you have the code that adds/updates a record in your table?

In my opinion this looks like a DB constraint issue. Are you trying to insert a new record in Order_detail table and order_header table simultaneously? If yes you will have to add the order_header record first and then set the order_header entity to the order_detail entity.


Shailesh Kini.
priya pillai
Ranch Hand

Joined: Sep 12, 2007
Posts: 57
thank you

i solved the problem..

the problem is I set the po_no which is the primary key of master table and FK of transaction table.i set that using seXX method in transaction table ejb

thank you for your reply
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Problem with CMR