Informatica parent child mapping

  down votefavorite I have a scenario where suppose saycountry      province      city      zip
ind           ts           hyd       xyz
ind          maha          mum       abc
Desired output:id   name         parent-id
1    india         1
2    telengana     1
3    hyderabad     2
4    xyz           3
5    mumbai        1
6    abc           5
I have to do it with informatica mapping any ideas how do I show this parent child relationship. I am not able to get the logic for thisThanksKumar

Thanks for the thoroughness. There was a mistake in moving the code over for the forum. The field names are correct throughout the original source code.
BASE_OBJECT_ID is used throughout.
I suspect the problem lies in the one-to-many sampleItem(s) relationship that is based upon the subclassed item class. (The relationship is actually "sampleItems" in the real code and somehow got changed in the move over.)
The problem may lie in the mapping of the attribute override in the child class to the referencing of the item class from the parent side of the relationship in the Sample class.
I further suspect this may be specific to Eclipselink based upon other postings I've seen on the web that have similar problems...
Any thoughts?
Edited by: Chris-R on Mar 3, 2010 9:56 AM

Similar Messages

  • Parent - Child mapping - ODI

    Hi experts,
    I have source as a below format, in .xls, this is parent- child relationship..
    Gen1     Gen2     Gen3     Gen4
    9000000009 blank     blank     blank
    blank     910000000 blank     blank
    blank     blank     9110000000     blank
    blank     blank     9120000009     blank
    blank     blank     blank     9121100009
    And trying the data into Oracle table with the below format.
    Gen1     Gen2     Gen3     Gen4
    9000000009               
    9000000009     9100000009          
    9000000009     9100000009     9110000000     
    9000000009     9100000009     9120000009     
    9000000009     9100000009     9120000009     9121100009
    Please help me what is the workaround I can follow to achieve using ODI.
    regards,
    Preet
    Edited by: 914626 on Mar 4, 2012 10:13 PM
    Edited by: 914626 on Mar 4, 2012 10:14 PM
    Edited by: 914626 on Mar 4, 2012 10:15 PM
    Edited by: 914626 on Mar 4, 2012 10:15 PM
    Edited by: 914626 on Mar 4, 2012 10:17 PM

    Thanks for the thoroughness. There was a mistake in moving the code over for the forum. The field names are correct throughout the original source code.
    BASE_OBJECT_ID is used throughout.
    I suspect the problem lies in the one-to-many sampleItem(s) relationship that is based upon the subclassed item class. (The relationship is actually "sampleItems" in the real code and somehow got changed in the move over.)
    The problem may lie in the mapping of the attribute override in the child class to the referencing of the item class from the parent side of the relationship in the Sample class.
    I further suspect this may be specific to Eclipselink based upon other postings I've seen on the web that have similar problems...
    Any thoughts?
    Edited by: Chris-R on Mar 3, 2010 9:56 AM

  • JPA One-To-Many Parent-Child Mapping Problem

    I am trying to map an existing legacy Oracle schema that involves a base class table and two subclass tables that are related by a one-to-many relationship which is of a parent-child nature.
    The following exception is generated. Can anybody provide a suggestion to fix the problem?
    Exception [EclipseLink-45] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.DescriptorException
    Exception Description: Missing mapping for field [BASE_OBJECT.SAMPLE_ID].
    Descriptor: RelationalDescriptor(domain.example.entity.Sample --> [DatabaseTable(BASE_OBJECT), DatabaseTable(SAMPLE)])
    The schema is as follows:
    CREATE TABLE BASE_OBJECT(
    "BASE_OBJECT_ID" INTEGER PRIMARY KEY NOT NULL,
    "NAME" VARCHAR2(128) NOT NULL,
    "DESCRIPTION" CLOB NOT NULL,
    "BASE_OBJECT_KIND" NUMBER(5,0) NOT NULL );
    CREATE TABLE SAMPLE(
    "SAMPLE_ID" INTEGER PRIMARY KEY NOT NULL,
    "SAMPLE_TEXT" VARCHAR2(128) NOT NULL )
    CREATE TABLE SAMPLE_ITEM(
    "SAMPLE_ITEM_ID" INTEGER PRIMARY KEY NOT NULL,
    "SAMPLE_ID" INTEGER NOT NULL,
    "QUANTITY" INTEGER NOT NULL )
    The entities are related as follows:
    SAMPLE.SAMPLE_ID -> BASE_OBJECT.BASE_OBJECT_ID - The PKs that are used to join the sample to the base class
    SAMPLE_ITEM.SAMPLE_ITEM_ID -> BASE_OBJECT.BASE_OBJECT_ID - The PKs that are used to join the sample item to the base class
    SAMPLE_ITEM.SAMPLE_ID -> SAMPLE.SAMPLE_ID - The FK that is used to join the sample item to the sample class as a child of the parent.
    SAMPLE is one to many SAMPLE_ITEM
    The entity classes are as follows:
    @Entity
    @Table( name = "BASE_OBJECT" )
    @Inheritance( strategy = InheritanceType.JOINED )
    @DiscriminatorColumn( name = "BASE_KIND", discriminatorType = DiscriminatorType.INTEGER )
    @DiscriminatorValue( "1" )
    public class BaseObject
    extends SoaEntity
    @Id
    @GeneratedValue( strategy = GenerationType.SEQUENCE, generator = "BaseObjectIdSeqGen" )
    @SequenceGenerator( name = "BaseObjectIdSeqGen", sequenceName = "BASE_OBJECT_PK_SEQ", allocationSize = 1 )
    @Column( name = "BASE_ID" )
    private long baseObjectId = 0;
    @Entity
    @Table( name = "SAMPLE" )
    @PrimaryKeyJoinColumn( name = "SAMPLE_ID" )
    @AttributeOverride(name="baseObjectId", column=@Column(name="SAMPLE_ID"))
    @DiscriminatorValue( "2" )
    public class Sample
    extends BaseObject
    @OneToMany( cascade = CascadeType.ALL )
    @JoinColumn(name="SAMPLE_ID",referencedColumnName="SAMPLE_ID")
    private List<SampleItem> sampleItem = new LinkedList<SampleItem>();
    @Entity
    @Table( name = "SAMPLE_ITEM" )
    @PrimaryKeyJoinColumn( name = "SAMPLE_ITEM_ID" )
    @AttributeOverride(name="baseObjectId", column=@Column(name="SAMPLE_ITEM_ID"))
    @DiscriminatorValue( "3" )
    public class SampleItem
    extends BaseObject
    @Basic( optional = false )
    @Column( name = "SAMPLE_ID" )
    private long sampleId = 0;
    Edited by: Chris-R on Mar 2, 2010 4:45 PM

    Thanks for the thoroughness. There was a mistake in moving the code over for the forum. The field names are correct throughout the original source code.
    BASE_OBJECT_ID is used throughout.
    I suspect the problem lies in the one-to-many sampleItem(s) relationship that is based upon the subclassed item class. (The relationship is actually "sampleItems" in the real code and somehow got changed in the move over.)
    The problem may lie in the mapping of the attribute override in the child class to the referencing of the item class from the parent side of the relationship in the Sample class.
    I further suspect this may be specific to Eclipselink based upon other postings I've seen on the web that have similar problems...
    Any thoughts?
    Edited by: Chris-R on Mar 3, 2010 9:56 AM

  • Parent-Child Hierarchy in Informatica

    Can anyone please tell me the solution for the below scenario in Informatica. I have seen this scenario in folkstalk.com Take a look at the following tree structure diagram. From the tree  structure, you can easily derive the parent-child relationship between  the elements. For example, B is parent of D and E.    The above tree structure data is represented in a table as shown below. SOURCE TABLE:  C1C2C3C4ABDHABDIABENULLACFNULLACGNULL  Here in this table, column C1 is parent of column C2, column C2 is parent of column C3, column C3 is parent of column C4. Design a mapping to load the target table with the below data. Here you  need to generate sequence numbers for each element and then you have to  get the parent id. As the element "A" is at root, it does not have any  parent and its parent_id is NULL. TARGET TABLE Seq_IDELEMENTParent_ID   1    A   NULL   2    B   1   3    C   1   4    D   2   5    E   2   6    F   3   7    G   3   8    H   4   9    I   4  Both Source and Target are Oracle tables.Please help me how to acheive this in Informatica.

    AA선릉야구장 역삼풀싸롱 OlO 4314 6363 강북풀싸롱, 명동풀살롱MM명동룸싸롱위치+가격++문의 한예슬실장 BEST EVENT로 화끈하게!~     AA선릉야구장 역삼풀싸롱 OlO 4314 6363 강북풀싸롱, 명동풀살롱MM명동룸싸롱위치+가격++문의 한예슬실장 BEST EVENT로 화끈하게!~     AA선릉야구장 역삼풀싸롱 OlO 4314 6363 강북풀싸롱, 명동풀살롱MM명동룸싸롱위치+가격++문의 한예슬실장 BEST EVENT로 화끈하게!~     AA선릉야구장 역삼풀싸롱 OlO 4314 6363 강북풀싸롱, 명동풀살롱MM명동룸싸롱위치+가격++문의 한예슬실장 BEST EVENT로 화끈하게!~     AA선릉야구장 역삼풀싸롱 OlO 4314 6363 강북풀싸롱, 명동풀살롱MM명동룸싸롱위치+가격++문의 한예슬실장 BEST EVENT로 화끈하게!~     AA선릉야구장 역삼풀싸롱 OlO 4314 6363 강북풀싸롱, 명동풀살롱MM명동룸싸롱위치+가격++문의 한예슬실장 BEST EVENT로 화끈하게!~     AA선릉야구장 역삼풀싸롱 OlO 4314 6363 강북풀싸롱, 명동풀살롱MM명동룸싸롱위치+가격++문의 한예슬실장 BEST EVENT로 화끈하게!~     AA선릉야구장 역삼풀싸롱 OlO 4314 6363 강북풀싸롱, 명동풀살롱MM명동룸싸롱위치+가격++문의 한예슬실장 BEST EVENT로 화끈하게!~     AA선릉야구장 역삼풀싸롱 OlO 4314 6363 강북풀싸롱, 명동풀살롱MM명동룸싸롱위치+가격++문의 한예슬실장 BEST EVENT로 화끈하게!~     AA선릉야구장 역삼풀싸롱 OlO 4314 6363 강북풀싸롱, 명동풀살롱MM명동룸싸롱위치+가격++문의 한예슬실장 BEST EVENT로 화끈하게!~     AA선릉야구장 역삼풀싸롱 OlO 4314 6363 강북풀싸롱, 명동풀살롱MM명동룸싸롱위치+가격++문의 한예슬실장 BEST EVENT로 화끈하게!~     AA선릉야구장 역삼풀싸롱 OlO 4314 6363 강북풀싸롱, 명동풀살롱MM명동룸싸롱위치+가격++문의 한예슬실장 BEST EVENT로 화끈하게!~     AA선릉야구장 역삼풀싸롱 OlO 4314 6363 강북풀싸롱, 명동풀살롱MM명동룸싸롱위치+가격++문의 한예슬실장 BEST EVENT로 화끈하게!~     AA선릉야구장 역삼풀싸롱 OlO 4314 6363 강북풀싸롱, 명동풀살롱MM명동룸싸롱위치+가격++문의 한예슬실장 BEST EVENT로 화끈하게!~     AA선릉야구장 역삼풀싸롱 OlO 4314 6363 강북풀싸롱, 명동풀살롱MM명동룸싸롱위치+가격++문의 한예슬실장 BEST EVENT로 화끈하게!~     AA선릉야구장 역삼풀싸롱 OlO 4314 6363 강북풀싸롱, 명동풀살롱MM명동룸싸롱위치+가격++문의 한예슬실장 BEST EVENT로 화끈하게!~     AA선릉야구장 역삼풀싸롱 OlO 4314 6363 강북풀싸롱, 명동풀살롱MM명동룸싸롱위치+가격++문의 한예슬실장 BEST EVENT로 화끈하게!~     AA선릉야구장 역삼풀싸롱 OlO 4314 6363 강북풀싸롱, 명동풀살롱MM명동룸싸롱위치+가격++문의 한예슬실장 BEST EVENT로 화끈하게!~     AA선릉야구장 역삼풀싸롱 OlO 4314 6363 강북풀싸롱, 명동풀살롱MM명동룸싸롱위치+가격++문의 한예슬실장 BEST EVENT로 화끈하게!~

  • Parent-child relation between Activities

    Hello,
    Is it possible to give parent child relationship between Activities within single Project? The requirement is, parent Activity to take part in overall scheduling whereas the Dates for parent Activity are determined by the child Activities attached to it.
    Thank you,
    Hemant

    Hi,
    In PS we  can map through the network activity and activity elemnents. For scheduling the projects the start date and end date of all  the activity elements are included in the respective network activity. for better understanding refer the following link.
    http://help.sap.com/saphelp_erp60_sp/helpdata/en/a9/8a853488601e33e10000009b38f83b/frameset.htm
    http://help.sap.com/saphelp_erp60_sp/helpdata/en/a9/8a853488601e33e10000009b38f83b/frameset.htm
    Regards,
    Nag.

  • 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..

  • Cascading parent/child inserts while avoiding uniqueness constraints

    Assume that I have two classes that I'd like to persist: MyObject and
    InternalObject. MyObject has an InternalObject field. That is, MyObject is
    the parent, InternalObject is the child in this one-to-one relationship.
    Steps involved:
    1) Enable ForeignKeyConstraints property in kodo.properties. That is add
    the line,
    kodo.jdbc.ForeignKeyConstraints=true
    2) In package.jdo, add the following kodo extensions for MyObject's
    InternalObject field mapping, i.e., io in my case.
    <field name="io" default-fetch-group="false">
    <extension vendor-name="kodo" key="jdbc-delete-action"
    value="cascade"/>
    <extension vendor-name="kodo" key="dependent" value="true"/>
    </field>
    The reasons that we have done these steps: we'd like kodo to properly
    re-order the sql statements if necessary in order not to violate
    parent/child dependencies during insertion, and also force cascading
    deletes in case we delete the parent object.
    Now comes the bulk of the algorithm.
    String sKey // key of the object to insert
    String sValue //value of the object to insert
    MyObject o = new MyObject(sKey, sValue);
    InternalObject io = new InternalObject(sKey,sValue); //using same values :)
    o.setInternalObject(io); //parent-child relation
    Object id = ((PersistenceCapable) o).jdoNewObjectIdInstance();
    ((PersistenceCapable)o).jdoCopyKeyFieldsToObjectId(id);
    kpm.currentTransaction().begin();
    try {
    Object trio = kpm.getObjectById(id, true);
    kpm.deletePersistent(trio);
    kpm.flush(); //apply deletes on the datastore
    } catch (ObjectNotFoundException oe) {
    System.out.println("First time!");
    kpm.makePersistent(o);
    kpm.currentTransaction().commit();

    If this is a question, the extension you have is only a directive to
    mappingtool to create cascade foreign keys. However, at runtime Kodo
    will rely upon the foreign key definitions in the schema. You should
    verify that the foreign key exists as you like in the schema. If you
    want to have child relationships to be deleted, you should use the
    dependent and element-dependent extensions.
    Ahmet Bulut wrote:
    Assume that I have two classes that I'd like to persist: MyObject and
    InternalObject. MyObject has an InternalObject field. That is, MyObject is
    the parent, InternalObject is the child in this one-to-one relationship.
    Steps involved:
    1) Enable ForeignKeyConstraints property in kodo.properties. That is add
    the line,
    kodo.jdbc.ForeignKeyConstraints=true
    2) In package.jdo, add the following kodo extensions for MyObject's
    InternalObject field mapping, i.e., io in my case.
    <field name="io" default-fetch-group="false">
    <extension vendor-name="kodo" key="jdbc-delete-action"
    value="cascade"/>
    <extension vendor-name="kodo" key="dependent" value="true"/>
    </field>
    The reasons that we have done these steps: we'd like kodo to properly
    re-order the sql statements if necessary in order not to violate
    parent/child dependencies during insertion, and also force cascading
    deletes in case we delete the parent object.
    Now comes the bulk of the algorithm.
    String sKey // key of the object to insert
    String sValue //value of the object to insert
    MyObject o = new MyObject(sKey, sValue);
    InternalObject io = new InternalObject(sKey,sValue); //using same values :)
    o.setInternalObject(io); //parent-child relation
    Object id = ((PersistenceCapable) o).jdoNewObjectIdInstance();
    ((PersistenceCapable)o).jdoCopyKeyFieldsToObjectId(id);
    kpm.currentTransaction().begin();
    try {
    Object trio = kpm.getObjectById(id, true);
    kpm.deletePersistent(trio);
    kpm.flush(); //apply deletes on the datastore
    } catch (ObjectNotFoundException oe) {
    System.out.println("First time!");
    kpm.makePersistent(o);
    kpm.currentTransaction().commit();
    Steve Kim
    [email protected]
    SolarMetric Inc.
    http://www.solarmetric.com

  • 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

  • Multi-Org Parent-Child LOV

    Issue Description:
    in Action BC (Table: S_EVT_ACT) we are trying to implement the following organization based parent child picklists/LOVs for Status->Status Reason
    [Status] - Activity Status field (col: EVT_STAT_CD)
    *Picklist: LOV Type = 'EVENT_STATUS', picklist BC: 'List Of Values Dynamic (REL)'
    [LN Status Reason] - customised field/column (Col: X_STATUS_REASON)
    *Picklist: LOV Type = 'LN_MISSED_ACTIVITY_REASON', picklist BC: 'PickList Hierarchical'
    *Pick Map: [LN Status Reason] = [Value], [Status] = [Parent] (Constraint = Y)
    in the Admin-Data LOVs:
    Type = EVENT_STATUS, Display Value/LIC = "Not Achieved", Organization = "Org 1"
    Type = LN_MISSED_ACTIVITY_REASON
    Display Value/LIC = "Reason 1", Parent LIC = "Not Achieved", Organization = "Org 1"
    Display Value/LIC = "Reason 2", Parent LIC = "Not Achieved", Organization = "Org 1"                                                                                          
    On UI, create new record in Account - Activities, selecting Status = "Not Achieved".
    Now when i try to select the Status Reason value, the drop down does not give me any value.
    If I set the Organization to blank on "Reason 1", then the "Reason 1" value shows up in the Status Reason drop down under Account - Activities.
    In SQL of the log file, for the Status Reason drop down, it always hard code a T1.BU_ID is null in the WHERE clause, this would explain why its blank in the dropdown
    Also as a test, If i remove all the pick map constraints for the [LN Status Reason] field (ie the only record in the pick map is [LN Status Reason] = [Value]), then the drop down works correctly (ie displaying both the values with Organization = "Org 1"), and in the SQL of the log file, instead of BU_ID is null, it has BU_ID = ? with variable binding.
    Is there a reason why it would hard code the BU_ID is null in the WHERE clause in the SQL, and how to overcome this to achieve my requirement.
    Just a further update due to character limit of the original description,
    The "Owner Organization Specifier" property on the table S_EVT_ACT is blank (not sure if its related to anything though)
    The user i'm using belongs to "Org 1" for both the employee's Organization and its Position's Organization
    Thanks

    This is exactly what I'm looking for...I just can't make it work. I have 2 tables (database and schema). They are related via a database_id column. My code is below if you are willing to help.
    HTML Header
    <script>
    function get_select_list_xml1(pThis,pSelect){
    var l_Return = null;
    var l_Select = html_GetElement(pSelect);
    var get = new htmldb_Get(null,html_GetElement('pFlowId').value,
    'APPLICATION_PROCESS=CASCADING_SCHEMA',0);
    get.add('P7_DATABASE',pThis.value);
    gReturn = get.get('XML');
    if(gReturn && l_Select){
    var l_Count = gReturn.getElementsByTagName("option").length;
    l_Select.length = 0;
    for(var i=0;i<l_Count;i++){
    var l_Opt_Xml = gReturn.getElementsByTagName("option");
    appendToSelect(l_Select, l_Opt_Xml.getAttribute('value'),
    l_Opt_Xml.firstChild.nodeValue)
    get = null;
    function appendToSelect(pSelect, pValue, pContent) {
    var l_Opt = document.createElement("option");
    l_Opt.value = pValue;
    if(document.all){
    pSelect.options.add(l_Opt);
    l_Opt.innerText = pContent;
    }else{
    l_Opt.appendChild(document.createTextNode(pContent));
    pSelect.appendChild(l_Opt);
    </script>
    Application Process
    BEGIN
    OWA_UTIL.mime_header ('text/xml', FALSE);
    HTP.p ('Cache-Control: no-cache');
    HTP.p ('Pragma: no-cache');
    OWA_UTIL.http_header_close;
    HTP.prn ('<select>');
    HTP.prn ('<option value="' || 0 || '">' || '- All Schemas -'
    || '</option>'
    FOR c IN (SELECT schema, schema_id
    FROM (SELECT schema, schema_id, database_id
    FROM schema_lookup
    WHERE database_id = :cascading_selectlist_item_1)
    LOOP
    HTP.prn ('<option value="' || c.schema_id || '">' || c.schema || '</option>');
    END LOOP;
    HTP.prn ('</select>');
    END;
    P7_DATABASE_ID Form Element Attribute
    onchange="get_select_list_xml1(this,'P7_SCHEMA_ID');
    P7_SCHEMA_ID LOV
    select SCHEMA d, SCHEMA_ID v from SCHEMA_LOOKUP
    where DATABASE_ID = :P7_DATABASE_ID
    order by 1

  • How to model parent child relationship with DPL? @Transient?

    Hello All,
    I want to model a parent entity object with a collection of child entities:
    @Entity
    public class Parent{
    @PrimaryKey
    String uuid;
    List&lt;Child&gt; children;
    @Entity
    public class Child{
    @PrimaryKey
    String id;
    I know that the DPL won't support automatic persistence where it'll recursively go through my parent bean and persist my children with one call. Is there a way of applying the equivalent to JPA's @Transient annotation on "children" so I can persist the children manually and have the engine ignore the collection?
    If not and I want to return to the user a Parent with a List named "children," do I have to create a new object which is identical to Parent, but doesn't have the BDB annotations and manually assemble everything? If possible, I'd like to avoid defining redundant objects.
    Thanks in advance,
    Steven
    Harvard Children's Hospital Informatics Program
    Edited by: JavaGeek_Boston on Oct 29, 2008 2:22 PM

    Hi Steven,
    The definition of persistence is here:
    http://www.oracle.com/technology/documentation/berkeley-db/je/java/com/sleepycat/persist/model/Entity.html
    And includes this: "All non-transient instance fields of an entity class, as well as its superclasses and subclasses, are persistent. static and transient fields are not persistent."
    So you can use the Java transient keyword. If that isn't practical because you're using transient in a different way for Java serialization, see the JE @NotPersistent annotation.
    In general a parent-child relationship between entities is implemented almost as you've described, but with a parentId secondary key in the Child to index all children by their parent. This enables a fast lookup of children by their parent ID.
    I suggest looking at this javadoc:
    http://www.oracle.com/technology/documentation/berkeley-db/je/java/com/sleepycat/persist/SecondaryIndex.html
    as it describes all types of entity relationships and the trade-offs involved. The department-employee relationship in these examples is a parent-child relationship.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • EJB 3, OneToMany that Acts As Tree, or Parent Child relationship support?

    (Sorry for the RoR reference)
    I first searched the forum and found this post that came close, but not exactly what I'm needing since my table doesn't reference the PK:
    http://forum.java.sun.com/thread.jspa?forumID=13&threadID=767913
    I have a table called Folder that represents a folder hierarchy. It has a 'Path' field and a 'Parent' field, and of course 'ID'. Each Folder knows its parent by the 'Parent' field, which references 'Path', not* 'ID'. Both are Strings.
    To find all the children of a Folder, the sql for a PreparedStatment might look something like this (shared for clarity of the situation):
    SELECT * FROM Folder
    WHERE Parent = ?Question:
    What are the proper annotations in EJB 3 / JPA to allow this kind non-primary key parent/child relationship mapping?
    Can I specify a named query that handles the logic and then reference it in the OneToMany annotation? Other cool tricks?
    Here is what I am trying (no runtime errors, but no results either). (Example simplified)
    @Entity
    @Table(name = "Folder")
    @NamedQueries(value = {@NamedQuery(.......)})
    public class Folder implements Serializable {
        @Id
        @Column(name = "ID", nullable = false, updatable = false)
        private Integer folderID;
        @Column(name = "Path", nullable = false)
        private String path;
        @Column(name = "Parent")
        private String parent;
        // v Here's the kicker v
        @OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.EAGER)
        @JoinTable(name="Folder",
            joinColumns={@JoinColumn(name="Parent")},
            inverseJoinColumns={@JoinColumn(name="Path")})
        private List<Folder> children;
        // getters and setters ....
    }Thanks!

    It looks like the relationship is bi-directional.
    Will this work...
    // Parent.java
    @Entity
    public class Parent implements java.io.Serializable {
    @Id
    public Long parentId;
    @OneToMany(cascade=CascadeType.PERSIST,mappedBy="parent")
    public Collection<Child> children;
    // Child.java
    @Entity
    public class Child implements java.io.Serializable {
    @Id
    public Long childId;
    @ManyToOne
    public Parent parent;  // target of mappedBy
    }Then, in your code (a session facade?), you'll create the parent first, create the children, then add the children to the parent. Your code is also responsible for maintaining the reference back to the parent.
    Parent p = new Parent();
    for(int i=0; i<10; i++) {
      Child c = new Child();
      p.children.add(c);
      c.parent = p;
    em.persist(p);

  • Find parent/child relationships At More Than 2 Levels

    Hello,
    Does anyone have a solution to find parent/child relationship for data more than 2 levels deep?
    I have a solution when there's a simple parent-child relationship but not when there's a grandparent-parent-child relationship or deeper.
    Ex. I have a table company_parent_child that stores the relationship betwen a company and it's direct parent.
    create table TEMP_COMPANY_PARENT_CHILD
    PARENT_ID NUMBER(10),
    COMPANY_ID NUMBER(10)
    insert into TEMP_COMPANY_PARENT_CHILD values (1, 10);
    insert into TEMP_COMPANY_PARENT_CHILD values (1, 11);
    insert into TEMP_COMPANY_PARENT_CHILD values (1, 12);
    insert into TEMP_COMPANY_PARENT_CHILD values (2, 13);
    insert into TEMP_COMPANY_PARENT_CHILD values (10, 100);
    insert into TEMP_COMPANY_PARENT_CHILD values (10, 101);
    insert into TEMP_COMPANY_PARENT_CHILD values (10, 102);
    insert into TEMP_COMPANY_PARENT_CHILD values (11, 103);
    1->
    ___10->
    ______100,101,102,
    ___11->103
    Companies 100, 101 and 102 are under parent 10 and grandparent 1.
    I need to create such a view or another temp table so that when I pass the parent ID, I will pull all the children on all levels. In addition, and this is the tricky part, when I join this new temp table or view to another data table without any parameters, the data should not be duplicate, ie. each company ID should appear only once.
    create table TEMP_JOIN
    company_id number(10),
    order_id varchar2(10)
    insert into TEMP_JOIN values (100, 'a');
    insert into TEMP_JOIN values (101, 'b');
    insert into TEMP_JOIN values (102, 'c');
    insert into TEMP_JOIN values (103, 'd');
    insert into TEMP_JOIN values (10, 'e');
    insert into TEMP_JOIN values (11, 'f');
    insert into TEMP_JOIN values (12, 'e');
    insert into TEMP_JOIN values (13, 'f');
    Thanks.

    start by learning CONNECT BY/START WITH. once you've
    written a query to read the grandparent-parent-child
    relationship, then come back with more questionsYes. we did look heavily into connect by/start with, in fact along with "connect_by_iscycle","connect_by_isleaf","connect_by_root" as well.
    Our dilemma is that when a joint is made between those two tables mentioned above TEMP_COMPANY_PARENT_CHILD and TEMP_JOIN, we are not able to create a view that would contain distinct company_ids, each mapped to a unique order id.
    The problem is we cannot have this type of joint when there are "n" level relationship between companies (or company_id). Basically, I think we should have our unique order id mapped to a unique key. This unique key should be a specialized key that we can know at anytime the entire path of the ancestry which we can know by sys_connect_by_path(company_id,'/') path.
    How do we know which path to take. The best bet is to "connect_by_isleaf" and just have the distinct "deep" path which form the specialized unique key. If you need help on this let me know. (A hint, sort by LEVEL and then do a rank after partitioning by company id and then filter the records by rank = 1, try this one!!!)
    So, we will eventually have a joint (say Table X) like
    PATH ORDER_ID
    /1/10/100 a
    /1/10/101 b
    /1/10/102 c
    /1/10 e
    /1
    /1/11/103 d
    /1/11 f
    I think this is the best view we can have to maintain a joint with no repetition along PATH as well as ORDER_ID. If you have any other thoughts, let me know.
    Then you query by path using INSTR to pull records by company_id.
    for example, if you want to get all the children for company_id "10" you would just say
    select * from X where INSTR(PATH,10,1,1) <> 0
    or if you want to get all the children for company_id "11" you would just say
    select * from X where INSTR(PATH,11,1,1) <> 0
    What do you think? Has anyone used the path information for traversing the tree? Or is there any article that tells us how to make effective use of sys_connect_by_path(company_id,'/') path.
    Thank you. Hope it made sense!

  • Import Manager - Import Parent Child Relationships

    I have a parent child relationship set up in console.
    Kits / Parts.
    Has Required = No
    Has Quantity = No
    I am trying to import the data for the relationship links using Import Manager.
    The source is a Excel file.
    Item Number <Kits>       Item Number<Parts>
    ACC-123                               ACC-1234
    ACC-123                               ACC-555
    I mapped the Item Number Kits and Item Number Parts.
    When I import, I am getting the following error
    <b>Import failed. Failed to find the aggregation record from its field values.
    Source record no: 1</b>
    I am able to import the same record using Data Manager if the file format is Text.
    Any help is appreciated.
    Helpful answers will be duly rewarded

    The key field that you use to load the relationship must be defined as:
    Unique................Yes
    Display...............Yes
    Multilingual..........No
    My problem was that I had defined Model Number as multiligual. When I changed this setting and loaded with Update Indices the load worked.
    I have not found anywhere in the literature that talks about this restriction. You can create the relationship in the Console. You can load this type of relationship in Data Manager. You can not however load them in Import Manager.

  • Import of parent/child relationships

    Hi,
    While importing the parent/child relationship using Import Manager,i selected the Relationship in the Destination table.After mapping the corresponding fields,alll the fields under Match Records tab are greyed out.How do i import the parent/child relationships?
    Thanks and Regards,
    Preethi

    Hi Preethi,
    Check the configuration options related to Relationships. In addition check the below link
    http://help.sap.com/saphelp_mdm550/helpdata/en/43/12036df94c3e92e10000000a1553f6/frameset.htm
    Importing Parent/Child Relationship Links
    Regards,
    Jitesh Talreja
    Edited by: Jitesh Talreja on May 5, 2009 4:17 PM

  • Query Help with Parent, Child, Child's Child

    Hi all,
    Need some help with a query.  I'm trying to create a stored procedure that is sort of like a Customer, Order, Order, Details.  In my situation the tables are different but nevertheless, I want to grab all the fields from the  Parent, Child,
    and Childs' Child, where the Parent.ParentID = @Parameter.  I tried this:
    CREATE PROCEDURE [dbo].[spGetCompleteProjectXML]
    @ProjectID int = 0
    AS
    SELECT *,
    (SELECT *,
    (SELECT *
    FROM PageControls
    WHERE (PageControls.ProjectPageID = ProjectPages.ProjectPageID))
    FROM ProjectPages
    WHERE (ProjectPages.ProjectID = @ProjectID))
    FROM Projects
    WHERE (ProjectID = @ProjectID)
    FOR XML AUTO, ELEMENTS
    RETURN 0
    I think I'm close, but it was my best effort.  Could someone help?
    thanks in advance

    Hi TPolo,
    Regarding your description, are you looking for a sample like below?
    CREATE TABLE customer(customerID INT, name VARCHAR(99))
    INSERT INTO customer VALUES(1,'Eric')
    INSERT INTO customer VALUES(2,'Nelson')
    CREATE TABLE orders(orderID INT,customerID INT)
    INSERT INTO orders VALUES(1,1);
    INSERT INTO orders VALUES(2,1)
    INSERT INTO orders VALUES(3,2)
    INSERT INTO orders VALUES(4,2)
    CREATE TABLE orderDetails(orderID INT,item VARCHAR(99))
    INSERT INTO orderDetails VALUES(1,'APPLE1')
    INSERT INTO orderDetails VALUES(1,'BANANA1')
    INSERT INTO orderDetails VALUES(2,'APPLE2')
    INSERT INTO orderDetails VALUES(2,'BANANA2')
    INSERT INTO orderDetails VALUES(3,'APPLE3')
    INSERT INTO orderDetails VALUES(3,'BANANA3')
    INSERT INTO orderDetails VALUES(4,'APPLE4')
    INSERT INTO orderDetails VALUES(4,'BANANA5')
    SELECT customer.customerID,customer.name,
    (SELECT orderId,
    SELECT item FROM orderDetails WHERE orderID=orders.orderID FOR XML AUTO,TYPE,ELEMENTS
    FROM orders Where customerID=customer.customerID FOR XML AUTO,TYPE,ELEMENTS)
    FROM customer WHERE customerID=1
    FOR XML AUTO,ELEMENTS
    DROP TABLE customer,orderDetails,orders
    If you have any feedback on our support, please click
    here.
    Eric Zhang
    TechNet Community Support

Maybe you are looking for

  • PP sub-contracting error

    Hi Experts, While creating routing with external operation details I am getting this error, same Mat.group is maintained in Mat.master and Info record Material class differs from material class  from info record Message no. 06354 Diagnosis The materi

  • Difference in idoc adapter header mapping between SP14 and SP19

    Hi All, i have a very strange problem.......i have 2 XI systems : XI-sandbox and XI-dev..... XI-sandbox is on XI3.0 SP19 whereas XI-dev is on XI3.0 SP14........... I have a file->XI->idoc scenario which is same on both XI-sandbox and XI-dev.... in re

  • Ease your worries about potential headphone jack problems for $6.50

    Just get one of these: http://www.radioshack.com/product.as...2559&hp=search It's a right-angle, -foot headphone cable extension with strain relief and a volume control. Actually, the reason I got one was because I use a pair of Grado SR-60's with my

  • The ActiveX control cannot be instatiated --VC++

    When I try to insert any Javabean ActiveX control in VC++ resource dialog(design time).. I get the following error.. "The ActiveX control cannot be instatiated".. If I create it at runtime..It does not get painted.. if I resize my application my cont

  • Approvals Management (AME)

    Hi All In the Approvals Management Implementation Guide Release 12.1 Part No. E13516-04 On page 5-5 it makes mention of the Oracle Approvals Management Developers Guide. But I cannot find this guide, looked on Metalink, Googled etc etc to no avail. A