How to delete parent child relation in Toplink

Hi All,
I have 3 tables A,B,C.
In Table A ,I am saving record.
Table B & C has parent child relation.
B-->Parent
C-->Child
So I want to save records in Table A.
And delete from child(C) 1st then from parent(B).
I m writing my code as,
em.getTransaction().begin();
em.persist(Table A);//save in Table A
em.remove(em.merge(Table B));//Remove from Parent
But how to delete records from child table then from parent table.
Thanks
Sandip

If you have a @OneToOne relationship between two entities, the join column information is used to order the SQL when you remove two entities. For example, if I have:
@Entity
public class Employee implements Serializable {
     @OneToOne
     @JoinColumn(name="ADDR_ID")
     private Address address;
...Then the following code runs regardless of the order of the remove calls.
          em.getTransaction().begin();
          Employee parent = new Employee();
          Address child = new Address();
          parent.setAddress(child);
          em.persist(parent);
          em.persist(child);
          em.getTransaction().commit();
          em.getTransaction().begin();
          parent = em.merge(parent);
          child = em.merge(child);
          // order of next two statements unimportant
          em.remove(parent);
          em.remove(child);
          em.getTransaction().commit();If I don't remove the parent and just the child I get the same error you do because of the FK from Employee to Address.
--Shaun                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Similar Messages

  • How can provide parent-child nodes relation ships?

    how can provide parent-child nodes relation ships?

    I was under the impression that scenegraph is like a JTree. But in JavaFX only leaf node rendering in scenegraph. This situation was confusing my mind. In JavaFX CustomNode must be extending and return a group for custom leaf. If we want to a create parent-child node hierarchy we are create CustomNode that return a group and this group contain an another group,etc. So there is maybe only a way. If you learning to JavaFX first time.This way don't look familiar.

  • How to delete parent table data even though it has child records

    hi all,
    How to delete parent table data even though it has child records.
    ex: delete from pa_request cascade constraints;
    But this command is not working .
    Regards,
    P Prakash

    833560 wrote:
    ex: delete from pa_request cascade constraints;cascade constraints is DROP table option. It can't be used with DELETE. You need to delete child rows first or drop foreign keys and recreate them with ON DELETE CASCADE. Then:
    delete from pa_request will automatically delete child rows. However, personally I don't like ON DELETE CASCADE. You can, by mistake, delete half of your database without even realizing it.
    SY.

  • Representating Hierarchical (Parent-Child) relation graphically using Swing

    Hi,
    I have to represent a hierarchical data which is having Parent-Child relation using Swing. I am not able to upload the image overhere, so I am represnting the data in such a way so that one can understand this problem. If anyone knows how to upload image on Sun forum, please let me know it will be great help for me.
    Parent Root - A
    Child of A - B, C, D
    Child of C - E, F, G
    Child of F - H
    Child of D - J, K
    The data needs to be represented in two formats-
    1. Tabular Format
    I am able to represent data in this format using combination of JTree and JTable. The data is getting represented in tabular format and I am able to expand and collapse the parent nodes to see the childs. The tabular data will look like below structure,
    A
    I_B
    I
    I_C
    I I_E
    I I
    I I_F
    | I |_H
    | I
    I I_G
    I
    I_D
    I
    I_J
    I
    I_K
    2. Graphical Format
    This is the other way in which I need to represent the data. The above shown tabular data needs to represented in graphical form. The end result should look like,
    I A I
    ____________________I__________________________
    ___I___ __I__ __I__
    I  B  I I  C   I I  D   I
    ____________________I____________ ______I________
    ___I___ __I__ __I__ __I__ ___I__
    I  E  I I  F   I I  G   I I  J   I I   K    I
    __I___
    I   H   I
    Each box representing alphabates will be a component (like JPanel) which will have details about the item to be displayed. The parent and child should be connected with each other using line. This representation should be created at runtime using the hierarchical data. Also the parent and child relations should be expandable/collapsible as they are in JTree.
    I am not able to find any component or any solution in Swing which can provide me this graphical representation. It will be great help if anyone can help me out in this.
    Thanks in advance.

    Sorry for inconvinience for the data representaion in graphical form. I don't know how this get jumblled. Please try to figure out the tabular/graphical representation using pen and paper as forum is not providing any help to upload an image.
    Sorry again for inconvinience.
    Thanks
    Manoj Rai

  • Why in case of parent child relation iterator fetching one duplicate record

    Hi,
    JDev Ver : 11.1.1.2.0
    Technology : JPA/TopLik Service Facade Data Control (Without using BC4J)
    I have created JPA/TopLink service facade from DB Tables and on facades I have crated DataControl which I have draged and droped on my screen to create input text, table etc.
    In my application, I have many tables having one to many relationships. (Primarykey foreign key).
    When I add more then one child columns (foreign key columns) for any one parent column (primary key column), in db its getting inserted properly but in iterator after refreshing also it showing one duplicate entry instead of actual entry.
    e.g.
    For one Account Id 1234 (primary key) , I am adding 3 account holders name (abc, xyz, pqr) in this case in db its inserting proper 3 entries but in iterator its showing
    1234 abc
    1234 xyz
    1234 abc
    so instead of pqr its again showing abc.
    To select account holders name I have used selectManyShuttle components.
    I have also tried tried dciter.refresh(DCIteratorBinding.RANGESIZE_UNLIMITED); to refresh iterator.
    This is generic problem on most of the screen in my application where parent child relation comes.
    regards,
    devang

    Hi,
    Thanks for your reply. I just emailed the screen shot to your email . Please verify and let me know your comment.
    Regards,
    Kiran Konjeti

  • Parent Child relation in one transaction throws error... (

    In nutshell, I have a parent->child relation ship in DB and due to the UI requirement, I created view link as Child->parent, it is giving a hack a lot of problems.... (it sounds silly but looks like I am loosing my mind over this)
    Let me explain my situation,
    - I have a table A with col-a and col-b. I have another table B with col-a (primary key) and col-c. (This way table A is a parent table)
    - ON UI side i created relationship like table B is parent and Table A is child using col-a
    - I need to create parent-child (one record for each) record programatically.........
    I tried following thing:
    - from backing bean, as soon as i create Table-B row first, i get error saying too many objects with same key (which is understandable because of table design..... and associaion must be throwing that error)
    - from EOImpl file, it doesn't even find the child record being created... so during commit I can't send the foreign key value from Table-a to Table-b
    Any suggestion is greatly appreciated?
    Thank you,
    -Raj

    that depends on how you implement the multiple selection of orders.. you have to pass the selectedValues to the backend or store the values in a map or list and pass it..

  • How to filter parent & child rows from tables while export usingData export

    Hi,
    I have a requirement of export schema. Assume there is a account details table and account transactions table under schema.They have parent child relation exist. if i filter accounts from account details the corresponding transactions in account transactions table should be filterd.How to achieve this?
    Regards,
    Venkat Vadlamudi
    Mobile:9850499800

    Not sure if this is a SQL and PL/SQL question or whether it's an Oracle Apps type question or a Database General.
    Whatever, you've posted in the wrong forum (http://forums.oracle.com/forums/ann.jspa?annID=599)
    You should post in a more appropriate forum e.g.
    PL/SQL
    General Database Discussions
    etc.
    locking this thread

  • How to handle parent-child dimension in OWB?????

    i have a dimension have many levels,and the amount of levels is varing,so i cannot use the wizard to define my dimension ,seems with OWB i can only define dimension with certain amount of levels.......
    my dimension data is stored with this format:
    child parent
    Los Angles US
    US WORLD
    it is called a parent-child relation ,how can i define dimension with parent-child relation witn OWB...
    Can OWB do it ?????

    i have a dimension have many levels,and the amount of levels is varing,so i cannot use the wizard to define my dimension ,seems with OWB i can only define dimension with certain amount of levels.......
    my dimension data is stored with this format:
    child parent
    Los Angles US
    US WORLD
    it is called a parent-child relation ,how can i define dimension with parent-child relation witn OWB...
    Can OWB do it ????? You must define a dimension, define the dimension levels and the hierarchy inside the dimension (a hierarchy can have as many levels as you want, parent-child relationship is a normal hierarchy concept - no rocket science here). Then you have to map the data source for the dimension levels appropriately. Please refer to the user manual, chapter 4 ("Defining dimensianal targets") for details.
    Regards:
    Igor

  • Hierarchy Parent Child Relation Storage

    Hello All,
                I need to display hier. info in parent-child format. Any ideas on how to store parent child relationship in an ODS....I can view this format in the infoobject display screen for hierarchy...but cannot get this format to display..
    EX: Parent - child1,2,3,4
          child1- child 1-1,1-2,...
          child2 - child 2-1,2-2...
    thanks

    Spanyal,
    You will have to write a program to store this information in an ODS object. You will have to use /BIC/h<IO> Table to read the data and update a custom table. You will have to do some basic checks like business content or not, plan version, time dependency etc in the entry screen and then the program can read the hierarchy table in the format you want.
    I am not aware of any simpler way to populate hierarchy data into an ods object in a meaningful fashion.
    -Saket

  • Parent child relation tables

    Hi experts,
    Please check it my code . in this procedure first cursor only inserted into t1 temp table not inserted second cursor please check it and modified the my code.
    i want inserted parent child relation table like bellow
    parent child
    a b
    a c
    a d
    b l
    b m
    b n
    c d like that only inserted
    PROCEDURE TEST_PARENTS_CHILD( p_TABLE VARCHAR2)
    IS
    CURSOR c(P_TABLE varchar2)
    IS
    SELECT p.table_name PARENT, c.table_name CHILD
    FROM user_constraints p, user_constraints c
    WHERE (p.constraint_type = 'P' OR p.constraint_type = 'U')
    AND c.constraint_type = 'R'
    AND p.constraint_name = c.r_constraint_name
    AND p.table_name = P_TABLE;
    CURSOR C1(p_child varchar2) IS SELECT p.table_name PARENT_TABLE, c.table_name CHILD_TABLE
    FROM user_constraints p, user_constraints c
    WHERE (p.constraint_type = 'P' OR p.constraint_type = 'U')
    AND c.constraint_type = 'R'
    AND p.constraint_name = c.r_constraint_name
    AND p.table_name = P_CHILD;
    type array
    IS
    TABLE OF T1%ROWTYPE INDEX BY PLS_INTEGER;
    t_data ARRAY;
    BEGIN
    FOR I IN C(P_TABLE)
    LOOP
    FETCH C bulk collect INTO T_DATA limit 1000;
    --- EXIT WHEN C%NOTFOUND;
    FORALL I IN 1..T_DATA.last
    INSERT INTO T1 VALUES T_DATA(I);
    FOR J IN C1(i.CHILD)
    LOOP
    FETCH C1 BULK COLLECT INTO T_DATA LIMIT 1000;
    --EXIT
    --WHEN C1%NOTFOUND;
    FORALL j IN 1..T_DATA.last
    INSERT INTO T1 VALUES T_DATA(j);
    end loop;
    END LOOP;
    END TEST_PARENTS_CHILD;
    Regards,
    Venkat

    You've been asked before on your previous questions (all of which still appear to be unanswered) to read the FAQ: {message:id=9360002} and post correct details of your question, and use {noformat}{noformat} tags to preserve your code/data formatting on the forum.
    But still you post a question lacking all the information and formatting.  If you can't be bothered to help us understand your issue (and read your code), why do you expect others will be bothered to try and help you?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Parent child relation in OBIEE -RPD Issue

    Hi,
    I created a star schema by taking two tables . Now i want to establish parent-child relation ship .
    Now by clicking create logical dimension ----->Dimension with parent-child hierarchy ,the member key is not found.Pls correct me where i went wrong .
    Thanks-Bhaskar

    I know you said you have primary key defined already but just to make sure, can you follow these steps:
    1) Double click on dimension table
    2) go to tab 'Keys'. check if your primary key is defined there.
    3) If not, in 'Key Name', type in the key name
    4) select the primary key(column) in 'Columns'.
    5) Click OK.
    and then try to create hierarchy by following these steps:
    1) Right Click on the dimension table
    2) Create Logical Dimension -> Dimension with Parent-Child Hierarchy...
    3) Click OK (if you are OK with default values)

  • Changing into parent-child relation

    Hi,
    I have a table which has the following fields and the table gives the identifier for parent-child relation:
    ID
    PARENT ID
    structure
    parentkey_field
    foreignkey_field
    Fields[]
    data[]
    1.ID is the numbering like 1,2,3...
    2.PARENT ID will give the relation like which structure is the child for which   structure.
      Example: I have two structures HEADER and ITEM.Then the IDs will be 1 and 2.The parent id for ITEM will be 1(ID OF HEADER).
    3.Structure is the header/item structure names.
    4.parentkey_field and foreignkey_field are defining the header-child relation identifier fields.
    5.fields[] is the table with all the fields of header and item.
    6.DATA[] is the table having the data of header/item fields.
    Now my requirement is to flatten this table into one more table(with field structure_name,fieldname,value) with parent-child relation.
    Can anyone suggest something.

    It would be better if you posted the code you tried first and then having others help you with what's wrong.  Flattening a hierarchy is not that difficult; why don't you give it a shot first?

  • How to create Parent Child relationship of Assets

    Hi All
    can any one provide the solution for the below mention requirment.
    Problem Description: How to create Parent Child relationship of Assets in below case.
    1. If asset Category of Child assets are different but both parent & child assets are already capitalized.
    2. If asset Category of Child assets are same but both parent & child assets are already capitalized.
    3. If asset Category of Child assets are same for new assets.

    Hi All
    can any one provide the solution for the below mention requirment.
    Problem Description: How to create Parent Child relationship of Assets in below case.
    1. If asset Category of Child assets are different but both parent & child assets are already capitalized.
    2. If asset Category of Child assets are same but both parent & child assets are already capitalized.
    3. If asset Category of Child assets are same for new assets.

  • ADF,how to delete parent record and related child record without manual cod

    Hi All,
    I'm using 11g adf.
    I have one parent table PAR and two child table CHD1 , CHD2 respectively.
    I'm inserting values in three tables , making a form having add , delete and edit buttons.
    Issue when i want to delete a record from PAR table , it gives child table record exists . i have did manual coding to delete the child records with related to the selected parent table PAR.
    Is there any process in ADF to delete the child records with respective selected parent record with out manual coding.
    thanks in advance.

    http://download.oracle.com/docs/cd/E14571_01/web.1111/b31974/bcentities.htm#BABHFJFJ
    John

  • How to delete parent and child records together ?

    Hi,
    I'm using Jdeveloper 11.1.2.2
    I want to delete a row from a table but it is showing: Caused by: java.sql.SQLIntegrityConstraintViolationException: ORA-02292: integrity constraint (TABLE1_TL_FK1) violated - child record found.So how can I delete a Child row and table row in one method ?
    I cannot access the child's VO because it is not added to the AM.
    Thanks,
    Nigel.

    John, as usually, is right with the pointer to the documentation he pasted. Just to make sure you read it carefully, let me hoghlight an important point here:
    "If the option is selected, then the composed entities do not perform the DELETE statement *on the assumption that the database ON DELETE CASCADE constraint will handle the deletion of the corresponding rows*."
    So make sure the database is setup for cascade delete as otherwise you still will not succeed
    Frank

Maybe you are looking for

  • I got the above error while i restore the standby database using RMAN backu

    Dear All, RMAN> crosscheck archivelog all; using target database controlfile instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=14 devtype=DISK specification does not match any archive log in the recovery catalogi got t

  • How do I access my raw settings for further use?

    I opened a jpg in CR, made some changes, opened the image, then saved (from within PS) and closed it. Later I needed to create a duplicate of this image and apply the same CR settings I'd used, but I can't find them. When I open the original jpg, all

  • Belle Browser. Entering address problem.

    Hi, I've 701 recently updated to 0609 version, The problem is with entering web address in address bar of default browser while browsing very long web pages. It was possible before update but now it is not. Check this link http://www.themobilefanatic

  • Loading a specific image using servlets

    Hello, I have a question regarding a servlet and my HTML. In my HTML page I should load/ reaload some GIF images that are being dynamically created on the serves: drawn with Java 2 D and afterwards GIF encoded. response.setContentType("image/gif"); G

  • User Exit for field  resb-wempf in MB21

    Hello Guru's,         I wish to put personal no. in this field resb-wempf for only a single material code.I used this Enhancement MBCF0002 and inserted my code also but while doing MB21 it is not stopping here please guide how to move ahead. Thanks i