Problem with cascade delete in CMP one-to-one relationship

I am not able to cascade delete for one-to-one relationship. Even though relationship seems to be setup correctly, record from the second table is not deleted.
Following is the structure of tables i am using:
First Table(vcc_lrmc) -- LRMCBean
lrmc_id pk (Bean field is id)
lrmc_dtl_id (Bean field islrmcDtlId)
Second Table (vcc_lrmc_dtl) -- LRMCDetailBean
lrmc_dtl_id (pk) (Bean field islrmcDtlId)
lrmc_id (Bean field id)
One to one bidirectional relationship has been setup with CMR fields moreLRMC and mainLRMC.
section of ejb-jar is as follows:
<ejb-relation>
<ejb-relation-name>LRMCMainToDetail</ejb-relation-name>
<ejb-relationship-role>
<multiplicity>One</multiplicity>
<relationship-role-source>
<ejb-name>LRMC</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>moreLRMC</cmr-field-name>
</cmr-field>
</ejb-relationship-role>
<ejb-relationship-role>
<multiplicity>One</multiplicity>
<cascade-delete/>
<relationship-role-source>
<ejb-name>LRMCDetail</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>mainLRMC</cmr-field-name>
</cmr-field>
</ejb-relationship-role>
</ejb-relation>
section of orion-ejb-jar is as follows:(Bidirectional mapping)
<entity-deployment name="LRMC" data-source="jdbc/VCCDS" table="VCC_LRMC">
<cmp-field-mapping name="moreLRMC">
<entity-ref home="LRMCDetail">
<cmp-field-mapping name="lrmcDtlId" persistence-name="LRMC_DTL_ID"/>
</entity-ref>
</cmp-field-mapping>
</entity-deployment>
<entity-deployment name="LRMCDetail" data-source="jdbc/VCCDS" table="VCC_LRMC_DTL">
<cmp-field-mapping name="mainLRMC">
<entity-ref home="LRMC">
<cmp-field-mapping name="id" persistence-name="LRMC_ID"/>
</entity-ref>
</cmp-field-mapping>
</entity-deployment>
Is there anything else need to be setup for Cascade delete or is there anything wrong the way one-to-one relationship has been setup.
Pls. advice.
Thanks
Dhiraj

Is it happening because of this bug.
Cannot create a 1:1 bi-directional CMR for entity beans when database tables are reverse engineered. (2447364)
Anyone, any idea on this ?
Cheers,
Dhiraj

Similar Messages

  • Problems with cascading delete with entities

    I have a problem with cascading delete. I have two entities, Notebook and Note. One instance of Notebook can have several instances of Note in a Collection< Note >. The two entities are joined with a join table notebook_note that have two columns, the PK from the table of Notebook and Note. Note is not aware of the relation.
    From the user interface some elements of the collection<Note> can be added or deleted. I want to delete an element of that collection and make it persisted on the DB.
    If I add some Note elements to the collection and then I EntityManager.merge(notebook) (see public void persistNotebook() code below), I have all them persisted on the DB.
    However, if I delete some preexisting Note elements, after the merge I found deleted only the corresponding rows from the join table notebook_note BUT the rows in table Note, that was belonging to the deleted instance of Notebook, are NOT removed.
    Till now I found a way to do that (see code UserBean below), but I think that there is a simpler and so better way to do that! I hope to receive some suggestions!!
    @Entity
    public class Notebook implements Serializable {
    private static final long serialVersionUID = 1L;
    private String userName;
    private Collection<Note> notes;
    public Notebook() {
    public Notebook(String userName) {
    this.userName = userName;
    notes = new ArrayList<Note>();
    @Id
    public String getUserName() {
    return userName;
    public void setUserName(String userName) {
    this.userName = userName;
    @OneToMany(cascade = {CascadeType.ALL}, fetch = FetchType.EAGER)
    public Collection<Note> getNotes() {
    return notes;
    public void setNotes(Collection<Note> notes) {
    this.notes = notes;
    @Entity
    public class Note implements Serializable {
    String note;
    public void setNote(String note) {
    this.note = note;
    public String getNote() {
    return note;
    @Stateful
    public class UserBean implements UserRemote {
    private static Logger log = Logger.getLogger(UserRemote.class);
    @PersistenceContext(unitName = "etourism-ejbPU")
    private EntityManager em;
    &hellip;&hellip;
    @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
    public void persistNotebook() {
    NotebookDao notebookDao = new notebookDao(em);
    notebookDao.merge(notebook);
    em.flush();
    public void deleteNotebookNote (&hellip;.) {
    &hellip;..
    //noteFound is the note I want to delete from the Collection<Note>
    notebook.getEvents().remove(noteFound);
    persistNotebook(); //see method above
    *//I have also to explicitally delete the associated note!!!*
    *NoteDao noteDao = new NoteDao(em);*
    *noteDao.remove(noteDao.read(noteFound.getId()));*
    public void addNotebookNote(&hellip;..) {
    //add new note to the collection<Note> of the Notebook
    Note newNote = new Note(&hellip;);
    notebook.getNotes().add(newNote);
    persistNotebook();
    Where:
    public class NotebookDao extends JpaDao<Notebook, String> {
    &hellip;&hellip;
    public abstract class JpaDao<T, PK extends Serializable> implements IDao<T, PK> {
    &hellip;..
    public void remove(T entity) {
    getEntityManager().remove(entity);
    public void merge(T transientObject) {
    getEntityManager().merge(transientObject);
    }

    Thank you gimbal2 for your answer.
    You are right saying that a single Note could be bound to multiple notebooks, when using a join table, so the cascade cannot be done automatically by JPA.
    However, in my case, a single Note is bound only to one Notebook, so I would like to drop the join table (as you rightly suggest): however when I declare in the Notebook, a relation 1:N in this way ...
    @OneToMany(cascade = {CascadeType.ALL}, fetch = FetchType.EAGER)
    private Collection<Note> notes;
    ... the join table is automatically created during the deploy.
    Sorry, I am a beginner in EJB3. What kind of relational mapping annotation should I use to have a straight 1:N relationship that doesn't generate a join table?
    I think that it should be better to avoid to modify the relationship (es. cascade option) directly in the created db tables and let the logic be declared in the entity code definition: am I right?
    Waiting for your suggestion ...
    thank you very much
    Enzo
    Edited by: contini on May 22, 2009 5:37 AM

  • Problem with cascade delete and remove bean

    I am working with two entity beans that map to two tables that have a foreign key relationship. Table B has a foreign key to A and in the database that foreign key is set for cascaded updates and cascaded deletes.
    The problem occurs when the the sytem first tries to remove bean 1 (mapped to table A) and then remove bean 2 (mapped to B) where bean 2 is associated with bean 1 with a foreign key relationship. The first remove works but then when it tries to remove bean 2 it throws a very ugly "CORBA TRANSACTION_ROLLEDBACK 9998" Maybe exception. My guess is that the reason is because bean 2's reocrd in the database was deleted when bean 1 was removed but the 'bean object' was not removed from the container.
    When I go into our Application Server and look at how it see's the tables, it show the wrong relationship. It shows a restrict delete and a restrict update realationship.
    My question is, am I wrong to think that this is a application server problem or a configuration problem? It seems to me that attempting to remove a non-existant record should not cause an error. It won't cause any SQL exceptions. Is this a flawed viewpoint? As a work around I made sure that the dependent records are deleted first but it kind of defeats the point of cascaded deletes.
    We have a limited number of support calls, should I use one or am I at fault here?

    If the database removes the record from the second
    table, why is the system trying to remove it once
    again? You should try to remove an entity from a
    single place, should it be the database or the
    application. Don't try to remove it twice.
    Regards,
    DimitarI could do this but it is a huge pain in my ass. The problem is that you might want to remove the dependent bean without removing it's parent. The object structure is a little questionable, I'll admit that. It is, as they say, the eleventh hour and I can't really change that now.
    The way this work is that the server gets a list of objects marked either as new, modified, or deleted. It then relates those changes back to the database.
    In this case we have two lists(which makes me realize where the class structure sucks.) In order to do what you suggest I would have to get all the deleted parent objects and then search all the deleted child objects for ones that have the parent's key in them.
    It would be prefferable to fix the class structure but again this is not an option.
    Anyone want to answer the question I asked?

  • I can't download from app store apps. if i try then open account and ask me shange payment type because there is a billing problem with a previous purchase. I download one game 0.99 and nothing more! help me. How can i contact with apple?

    I can't download from app store apps. if i try then open account and ask me shange payment type because there is a billing problem with a previous purchase. I download one game 0.99 and nothing more! help me. How can i contact with apple?

    Click here and ask the iTunes Store staff for assistance.
    (102938)

  • HT4009 Do you understand me ? I want money back.Because I have problem with LINE In App Purchase.And no one try to resolve this problem.And the answer of NEVER LINE JAPAN they don't have responsibility.I think it will be effect with APPLE image also.I wan

    Do you understand me ? I want money back.Because I have problem with LINE In App Purchase.And no one try to resolve this problem.And the answer of NEVER LINE JAPAN they don't have responsibility.I think it will be effect with APPLE image also.I want you to help me everyways to refound my monet back.Could you?

    Contact iTunes Store Support.

  • HT5137 I made a purchase with my debit card on The Simpson Tapped out game, And now my game won't open. It just kicks me out every time I click on it. How do I fix this problem with out deleting my app?

    I made a purchase with my debit card on The Simpson Tapped out game, And now my game won't open. It just kicks me out every time I click on it. How do I fix this problem with out deleting my app?

    Personally, I would never use a debit card online, for security reasons.  If your card gets hacked its your money that is stolen.  At least with a credit card it is the card providers money that is stolen.
    Anyway,  I would delete the app and re-install.  If you paid for the app in the first place you will be able to re-install free of charge.  Also, the app should allow the in-app purchase to happen again as it should recognise that you have already purchased it previously.
    Finally, it might be that the 3G doesnt have as much ram as more recent models of iphone and you may have applications running in the background that are preventing the app to function with the in-app purchase unless you shut down any apps eating all you memory that are running in the background.  Shut-down these apps (and the simpson tap out app) by exiting to your home screen and double-tapping the home button to show what apps are running in the background.  press and hold any of the open apps until it starts shaking.  close all the apps down.  exit then re-launch the app.
    good luck.

  • Having problem with my hp officejet j6480 all-in-one printer

    i am having problem with my HP officejet j6480 all-in-one printer it prints very slow
    the operating system is windows 7  32-bits i download full driver software but that did not fix the problem
    This question was solved.
    View Solution.

    Hi - Does it print slowly from all applications or just certain ones?  In either case, you can try following the steps in this document.
    In addition, try going into Control Panel, Printer, right click on the printer and choose Printer Properties.  Click on the Advanced Tab and select Print Direcly to the Printer.
    Hope that helps.
    Say Thanks by clicking the Kudos thumbs up. Please mark the post that solves your problem as an Accepted Solution so other forum users can utilize the solution.
    I am an HP employee.

  • HT202159 I bought the  UnZipper, vV1.0.00 (4+) , couldn't download (it reported an error in the end), didn't install it but still, I was charged by you. Also I can't update "The Unarchiver", could I have any problems with my Mac? It's a one-year-old Mac P

    I bought the  UnZipper, vV1.0.00 (4+) , couldn't download (it reported an error in the end), didn't install it but still, I was charged by you. Also I can't update "The Unarchiver", could I have any problems with my Mac? It's a one-year-old Mac Pro Laptop. Could you help me please?

    Check under App Store/Purchases for your purchase. Install it from there again. ... Hopefully you did buy this from Apple's App Store, right!

  • I bought the  UnZipper, vV1.0.00 (4 ) , couldn't download (it reported an error in the end), didn't install it but still, I was charged. Also I can't update "The Unarchiver", could I have any problems with my Mac? It's a one-year-old Mac Pro Laptop

    I bought the  UnZipper, vV1.0.00 (4+) , couldn't download (it reported an error in the end), didn't install it but still, I was charged. Also I can't update "The Unarchiver", could I have any problems with my Mac? It's a one-year-old Mac Pro Laptop. Could you help me please?
    Mac Pro, Mac OS X (10.6.8)

    Check under App Store/Purchases for your purchase. Install it from there again. ... Hopefully you did buy this from Apple's App Store, right!

  • HT2534 Hello! I have a problem with a credit card. I bought one program, after that i wanted buy one more, but it wrote that with my card something wrong. After that i wanted change my card (VISA) on "NONE". But there no NONE! I can't download FREE apps!

    Hello! I have a problem with a credit card. I bought one program, after that i wanted buy one more, but it wrote that with my card something wrong. After that i wanted change my card (VISA) on "NONE". But there no NONE! I can't download FREE apps! Than I wanted make new account and select NONE, but there no NONE, there only cards. Help, please!

    Hey Shamannnig!
    Here is an article that can explain a little more about this situation:
    Why can’t I select None when I edit my payment information?
    http://support.apple.com/kb/ts5366
    Thanks for using the Apple Support Communities!
    Cheers,
    Braden

  • Cascade delete in CMP 1:M relationship

    All,
    I have 2 CMP entity beans with 1:M relationship and cascade delete option setup. All functions of Add/Mod are working fine.
    Even cascade delete is getting trigged but not executing properly every time. Out of more than 100 records in the child table, only 99 are getting cascade deleted. I am deploying the beans using embedded OC4J which comes with JDeveloper.
    Is anyone aware of any such limitations or faced similar problem before ? Database tables don't have any integrity constraint setup.
    Thanks,
    Dhiraj

    The problem is that by making the AddrXRef privately owned it cannot be reparented. Once it is removed from it's parent's list (either one) it will be deleted. To achieve what you're trying to do you'll need to delete the old incorrect AddrXRef and replace it with a new correct one.
    From the TopLink Developer's Guide[1]:
    When you tell TopLink that a relationship is privately owned, you are specifying that:
    * If the source of a privately owned relationship is deleted, then delete the target.
    * If you remove the reference to a target from a source, then delete the target.
    --Shaun
    [1] http://www.oracle.com/technology/products/ias/toplink/doc/10131/main/_html/uowbas007.htm#i1134011

  • Problem with cascading dependent LOV query running when it should not

    I have a page fragment with a regular ADF form on it that I use to add new entries to a table. This form has many fields on it with LOV’s associated with them. I have dependent LOV’s on some of them. The one case I have is I have three fields A, B, and C. Field C is dependent on A and B. The problem I seem to be having is when I enter a value for field A using it’s LOV, I get an hourglass for a long time after I select it and before it is displayed on the form. If I delete field C from the form the problem goes away. If I change the query behind the view for the LOV for field C to include a rownum < 20 in the where clause the problem goes away. My question is, why would the selection of a value for field A cause the query to fire for field C’s LOV view and how can I stop it. I don’t really want to use the rownum in the where clause.

    i had lot of question?
    The problem I seem to be having is when I enter a value for field A using it’s LOV, I get an hourglass for a long time
    ok. are using? any complex query to pick the lov 'a' .
    Answer: The LOV for A is based on a read only non-EO view with a SQL that is not really very complex. The LOV definition does set multiple values when the selection is made to blank out dependent fields in the data model used by the main form.
    after I select it and before it is displayed on the form.
    here i cant undestud?
    Answer. The order of things is I open the main form, I click the mag glass to open the LOV popup, I select the row I want and click the OK button. Navigation returns to the main form where I get the hourglass waiting for the selected value to be displayed in the field on the main form.
    If I delete field C from the form the problem goes away. If I change the query behind the view for the LOV for field C to include a rownum < 20 in the where clause the problem goes away.
    ok.
    why are you going to delete the value of c?. At intial stage you can make empty after selecting a and/or b you can load into c.
    Answer: I physically deleted field C from the main form to see if that was what was causing the long delay. When I run the main form without field C I do not get the hourglass. That is how I know they are related.
    My question is, why would the selection of a value for field A cause the query to fire for field C’s LOV view and how can I stop it.
    you may set partial trigger to c depends for 'a'.
    or else lov 'c' query depends on 'a'
    Answer. The query for C's LOV does depend on the value returned when I select a value for A. They are cascading LOV's. Will setting the partial trigger stop the SQL for field C from running? Is the SQL running because I'm blanking out field C when I change the value for field A?
    am not sure i understud correctly. can you pictuarize you problem with an example.

  • Keyboard problems with Enter, delete, backspace, and right/left arrows

    In some applications, such as Yahoo and this message block right now !!, when composing a message, the arrow keys and delete, backspace keys become non responsive. Various ones will work on a random basis.
    I am getting double "carriage returns" also. Maybe this is why in Omegle when I press ENTER, it will not post a chat message; it will bring up a scroll box and for me to post the comment, I have to use the mouse to click ENTER.
    I have changed batteries in my keyboard, uninstalled /reinstalled Firefox. I have checked the above websites in Chrome and other browsers, and there are no problems.
    This has happened before, I don't recall what the solution was or if it just went away.'''
    Affected sites -- at least these
    http://us.mg6.mail.yahoo.com/neo/launch?ncrumb=Fx5R4O7ccqb&.rand=1041364415&nmig=yes#
    http://omegle.com/
    https://support.mozilla.com/en-US/questions/new?product=beta&category=b2&search=Keyboard+problems+with+Enter%2C+delete%2C+backspace%2C+and+right%2Fleft+arrows&showform=1

    PROBLEM SOLVED: http://forum.archlinux-br.org/viewtopic.php?id=1257
    Solution posted on Brazilian Archlinux forum. Credits to user "920608".
    [cache]
    /etc/xorg.conf
    Section "Files"
             #RgbPath "/usr/X11R6/lib/X11/rgb"
    EndSection
    Section "ServerFlags"
               Option "AutoAddDevices" "False"
    EndSection
    C'ya

  • Problem in cascade-delete

    I've using cascade delete for delete rows from two entity beans.......
    but my problem is that if I'm doing it from ejb side...i.e. setting "fk_constraint" to false, and setting cascade-delete in ejb-jar.xml (& not in database), then its working fine....
    but if I remove these tags from the ejb-jar and in the database, specify foreign key and ON DELETE CASCADE, then its not working....it is giving the error...
    "can't add or update a child row...foreign key constraint fails".....
    I've read somewhere that this cascade delete option should be specified either on the ejb side or on the db side..and not on both the sides......but in run-time only ejb side is working...
    Plz. help me out coz I want the deletion from db side...as thr are some other tables not used in ejb but dependant on the one used in the ejb side.

    I think that you must specify <cascade-delete/> tag in ejb-jar.xml ONLY. But not in database.

  • Master/Details tables with CASCADE delete giving "table mutating" error

    Hi,
    I have two tables in a master/details configuration (table 1 is "master", table 2 is "details").
    The details has a FK contraint relation to the master with a CASCADE delete (so when the master is deleted, all associated details are deleted).
    The master table has a column "last_updated_datetime" which is updated by a master table update trigger whenever most (excluding the last_updated_datetime column) columns are updated.
    The details table has an update trigger which also updates the master table's last_updated_datetime column (whenever a detail row is changed).
    The details table also has a delete trigger which also updated the master table's last_updated_datetime column (whenever a detail row is deleted).
    The problem I have is: When the master record is deleted, which cascade deletes the details record(s), the delete trigger on the details table throws a "table is mutating" error.
    I understand that the "mutating" error is "correct" because the master record is being deleted.
    But is there some way I can get around this problem (for example, having the details table delete trigger not update the master table last_updated_datetime) when it's this cascade delete?
    Thanks for your help!

    create table master (
      id number primary key,
      changed date not null
    create table detail (
      id number primary key,
      master_id references master (id) on delete cascade
    create or replace package pkg is
      master_deleted boolean := false;
    end;
    create or replace trigger bds_master
      before delete on master
    begin
      pkg.master_deleted := true;
    end;
    create or replace trigger ads_master
      after delete on master
    begin
      pkg.master_deleted := false;
    end;
    create or replace trigger adr_detail
      after delete on detail
      for each row
    begin
    if not pkg.master_deleted then
        update master
           set changed = sysdate
         where id = :old.master_id;
      end if;
    end;
    insert into master values (1, sysdate - 10);
    insert into detail values (11, 1);
    insert into detail values (12, 1);
    insert into master values (2, sysdate - 10);
    insert into detail values (21, 2);
    insert into detail values (22, 2);
    insert into master values (3, sysdate - 10);
    insert into detail values (31, 3);
    insert into detail values (32, 3);
    commit;
    select * from master order by id;
            ID CHANGED                                                             
             1 01.09.08                                                            
             2 01.09.08                                                            
             3 01.09.08                                                            
    select * from detail order by id;
            ID  MASTER_ID                                                          
            11          1                                                          
            12          1                                                          
            21          2                                                          
            22          2                                                          
            31          3                                                          
            32          3                                                          
    delete detail where id = 21;
    select * from master order by id;
            ID CHANGED                                                             
             1 01.09.08                                                            
             2 11.09.08
             3 01.09.08                                                            
    select * from detail order by id;
            ID  MASTER_ID                                                          
            11          1                                                          
            12          1                                                          
            22          2                                                          
            31          3                                                          
            32          3                                                          
    delete master where id in (1, 2);
    select * from master order by id;
            ID CHANGED                                                             
             3 01.09.08                                                            
    select * from detail order by id;
            ID  MASTER_ID                                                          
            31          3                                                          
            32          3                                                           Regards,
    Zlatko
    Edited by: Zlatko Sirotic on Sep 11, 2008 11:15 PM
    This is disaster - ten attempts to format code!

Maybe you are looking for

  • Game center on two iPads and one Apple ID

    I own 2 iPads and use a single Apple ID so I have the same apps and music on my two devices. When my wife created an account on the second iPad it shows no games because they were purchased under my account. Please tell me I'm missing something and t

  • Printing problem in ical

    I am trying to print my Dec. calendar and both in print preview and the actual print out it will not include the events listed under Dec. 31st. The events appear on the screen but not when I select print from the file menu. Any suggestions?

  • No sound after (kernel)update 64bit

    Hey I just rebooted my PC the first time after the new kernel update. Now sound is not working anymore at all... But the soundcard (Audigy 2 ZS) is still recognized (e.g. via alsamixer), and kmix does not give any error message. Everything seems to w

  • Webcenter -Content can be socialized ???

    Hello, We are work on POC and here I need your suggestions and help. We have an application using Site Studio and Webcenter Content. Our application shows different electronic products in each secondary page. Its working fine. Now we want our user to

  • [SOLVED] Grub Error "Read or write outside of disk hd0"

    Trying to install Arch Linux (as per client request) on an old Seagate Mirra Personal Server. I reflashed the bios to get rid of the Seagate modified ROM and put the standard, stock, VIA bios image on there. Everything boots fine, it boots windows fi