This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques and have Mario Casciaro & Luciano Mammino on-line!
See this thread for details.
Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

CMR Questions

 
Ranch Hand
Posts: 229
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have two entity beans with a 1:Many CMR relationship. "Order" has many "OrderItem". An "Order" has an order number as its primary key. An "OrderItem" has an item number as its primary key, and it also has an order number that indicates the exact Order it belongs to. An "OrderItem" cannot exist without an "Order". That is, if I delete the "Order", all the related "OrderItem" will also be deleted implicitly.
I don't have problem coding the OrderItemBean, but I have with the OrderBean.
public abstract class OrderBean implements EntityBean {
public abstract String getOrderNumber();
public abstract void setOrderNumber(String orderNumber);
// CMR fields
public abstract void setOrderItems(Collection orderItemsLocal);
public abstract Collection getOrderItems();
...
}
Questions:
(1) If I call Order.remove(), will the related Order Items get deleted from the database?
(2) Within OrderBean, if I call setOrderItems() with an Empty Collection, does it delete the related Order Items from the database, or does it merely remove the relationship only?
Thanks in advance.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Search your appserver documentation for "cascade delete" or something like that. It should be possible.
 
Edmund Yong
Ranch Hand
Posts: 229
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using the J2EE implementation along with Cloudscape database.
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From ejb-jar_2_0.dtd
<!ELEMENT cascade-delete EMPTY>
<!--
The cmp-field element describes a container-managed field. The
field element includes an optional description of the field, and the
name of the field.
Used in: entity
-->
so inside a relationship, on the side of the relationship where the multiplicity is "Many" you have to specify <cascade-detele/>:
<multiplicity>Many</multiplicity>
<cascade-delete/>
 
You didn't tell me he was so big. Unlike this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic