Toplink one to many relationship

I am working on DAO layer for One to many relationship
how can we get the list child objects based on parent id..
we are using toplink ...

Hi,
If you are using with JPA, try this:
em.createQuery("select c from child c where c.parent.id = :id").setParameter("id", parentObject.getId())
                                                                                       .getResultList();

Similar Messages

  • How to change the fetch size for a one-to-many relationship

    With Toplink 10.1.3, since using scrollablecursor is a prerequisites for changing the fetchsize on a query (using the setFetchSize), I am wondering if it would be possible to change the fetchsize of the query which is associated to a one-to-many relationship.
    So, is this possible? How ?

    In TopLink 10.1.3 you can set the fetch-size on any query, it has nothing to do with using a ScrollableCursor.
    Example:
    readQuery.setFetchSize(100);
    To set the fetch size on a mapping query use,
    mapping.getSelectionQuery().setFetchSize(100);
    In 10.1.3 you can only set this in code, not currently through XML or the Mapping Workbench. In 10.1.3.1 you should be able to set the value through XML as well.

  • One to many relationship leads to recursion?

    Hi,
    I've created a web services function which returns an object retrieved from a database using the persistence api (the class was generated by the Netbeans 5.5 "Entity Class from Database" feature.
    I can successfully return an object which has no foreign keys. However, when I try to retrieve an entity which is on either side of a 1:N relationship, I receive a stackOverflowError.
    Here's my sample schema (I'm using Derby bundled with SJAS 9 for testing)
    create table Address (
       Id int not null,
       StreetName varchar(255),
       City varchar(255),
       PostalCode varchar(255),
       Party int,
       primary key (Id)
    create table Party (
       Id int,
       Name varchar(255),
       primary key(Id)
    alter table Address add constraint foreign key (Party) references Party;So as you can see, one Party might have many addresses.
    I can retrieve either an Address or Party from the database using something like:
    em.createNamedQuery("Party.findById")
       .setParameter("id", 1)
       .getSingleResult();When I try to return it, I get a stackOverflowError in the server log. I'm using the default Toplink provider so enabling full logging on this, I can see the SQL.
    When retrieving an address, it selects all of the address fields and correctly binds the supplied Id value. It then performs a select on the Party table using the Address.Party value. This in turn causes it to attempt to retrieve an Address. After three queries, the error is thrown.
    I can't see why the above schema should cause this problem. Where an Address is requested, I would expect it to retrieve the address fields, including the value of the Party field but not the Party object itself. On the other hand. when a Party is retrieved, I would expect it to recurse through and return a collection of Address objects.
    Have I misunderstood this or am I missing some fundamental point about JAX-WS?
    Thanks for your help,
    -Phil

    You have to set both sides of the relations...
    for example to do this in a more seamless manner:
    public UserProfile
         public void addLog (UserActivityLog activity)
              logs.add (activity);
              if (!equals (activity.getUserProfile ()))
                   activity.setUserProfile (this);
    Now this is the most primitive of ways to maintain two sided relations.
    There are a lot of other patterns to get around this.
    If you want to set the UserActivityLog to a specific UserProfile without
    having a firm reference to ther UserProfile, you should get the object
    from the database/persistenceManager... as you are using application
    identity, you can do something like pm.getObjectById.
    JDO does not do magic references. If you set something to null, it will
    remain null until you set it.
    Srini wrote:
    Hi Guys
    I am trying to create a one to many relationship between 2 JDOs.
    UserProfile - User JDO having user info
    UserActivityLog - JDO having user log info
    UserProfile -- UserActivityLog
    1 many
    UserProfile - has a collection of UserActivityLog objects
    UserActivityLog - has a reference to UserProfile
    Qn 1:
    I created a UserProfile along with a collection of 2 UserActivityLog
    objects.
    Navigation:
    Now given a UserProfile object,i am able to get the UserActivityLog objects.
    But given a UserActivityLog object ,i get a NULL UserProfile object.
    Issues:
    Why this is happening???Do i need to set the reference for "UserProfile" in
    UserActivityLog before inserting???
    If so,then how do i add a UserActivityLog to an existing
    UserProfile???cos,if i create a UserActivityLog with reference to
    UserProfile ,then it will throw a Duplicate Key violation for UserProfile as
    it is already persisted in DB.
    It will be great if you can direct me to some one to many relationship
    examples already implemented.
    Thanks
    Srini
    Stephen Kim
    [email protected]
    SolarMetric, Inc.
    http://www.solarmetric.com

  • ADF One to Many relationship

    I'm a bit confused on how to create one to many relationships with ADF. Let's say I have a make and model table. One make can have many models. Now let's say I create a Business Facade like this (I'm using JavaBeans):
    public Collection getMakes () { ... }
    Ok, my data control now has the collection for makes. And I want to do something like this
    public Collection getModels (Make make) { ... }
    I can't make this work because ADF will detect it as a method accesor. How does this work?
    Regards,
    Néstor Boscán

    Maybe looking at how TopLink does it, can help you.
    Try creating TopLink objects for a master detail set of tables (dept-emp).
    This will create two beans that should be similar to your beans. Look at their structure to see how they work.
    The ADF TopLink workshop has the steps to show you how to do this.
    http://www.oracle.com/technology/obe/obe9051jdev/ide1012/adfworkshop/buildingadfapplicationsworkshop.htm

  • Techniques to eliminate ripple loading in one to many relationships

    Hi,
    In my domain model, I have a class O that has a one to many relationship with class M. The relationship is mapped in TOPLink as a one to many from O to M, and a one to one from M to O.
    An end user logs into our application that has an otherwise cold TOPLink cache and executes a use case that will render several to many aspects of each O instance, and there are many O instances to render a majority of the time.
    The first time a question is asked of an O instance that requires its M instances to answer the question, TOPLink will detect the unstubbing of that ValueHolder, and cause a SQL query to pull in the necessary M instances for that O instance.
    One technique to combat this ripple load is to mark the relationship between O and M to "useBatchReading". I am motivated to attempt a different technique in the particular scenario I am experiencing though.
    Another technique would seem to be to fetch all of the M instances for all of the O instances to be rendered, compute the relevant Collection of M instances for each O instance and then call mValueHolder.setValue(readCollectionOfMs) on each O instance. Is this technique feasible? Seems like it doesn't align with the intent of the TOPLink API.
    Are there any other techniques that can be used to solve this issue as well?
    Thanks,
    Doug

    Doug,
    What I believe you want is join and batch reading configured on the queries of your specific use case. That gives you much finer control then configuring these on the mappings.
    With TopLink you should have your use cases issue a fixed quantity of SQL statements irrelevant of the # of objects returned from the root query.
    Have you taken a look at the performance tuning chapter in the documentation?
    I hope this helps,
    Doug

  • What types of containers need to be used for one-to-many relationships

    While looking at toplink examples, I noticed that synchronized containers only are being used for one-to-many relationships even though it's not required by the documentation.
    Is it required?
    Also how does merge affect it? I'm gettning concurrent modification exceptions from time to time, while using iterators for containers from these relationships.
    Does it mean that I have to use enumeration on vectors only and toplink merge isn't atomic? So there is no isolation when toplink merges the data from unit of work into identity maps?
    There is nothing about thread-safety and threading aspects of accessing containers for CollectionMapping based relationships. Please advise.

    Non synchronized containers can be used but may require some extra code to handle concurrent access. If you are accessing the objects from the shared cache (not cloned in a UnitOfWork) then you will need to isolate your iteration within a synchronized block, synchronized on the collection itself, or handle the ConncurrentModificationException if they happen rarely.
    Because these are shared instances of these collections other threads may be writing to them while they are being read from.
    --Gordon

  • ONE-to-MANY relationship between tables and forms in APEX

    I recently started using APEX and I have run into an issue.
    I have a ONE-TO-MANY relationship between two tables, A1 and A2, respectively.
    A1:
    A1_ID
    Item
    A2:
    A2_ID
    SubItem
    A1_ID
    I have 2 forms (lets call it F1 and F2) that I use to capture data for A1 and A2.
    On F2, I have the following fields that are setup to capture data:
         A2.A1_ID
    **A1.Item (this is a drop down that is populated using a SELECT statement where the select uses A1.Item field)
         A2.SubItem (user would enter SubItem)
    Note: A2.A2_ID is populated using a SEQ
    Everytime I pick **A1.Item on F2, is there a way to link to A1 table and display A1.A1_ID for every **A1.Item selected on F2?
    If so, I want to store the value captured in F2 for the A1_ID field into A2 table to maintain my 1-to-MANY relationship.
    If this will work, how do I go about implementing this solution?
    Can someone help me?

    I think it sounds like you are asking for a Master-Detail form. Try that and see what you get.
    chris.

  • Urgent : java bean having bidirectional one to many relationship

    Hi,
    We have complex requirement in our application.
    We need to copy java bean having bidirectional one to many relationship to another javabean having bidirectional one to many relationship..
    E.g
    Class Basket1 {
    public String color;
    pubic String type;
    public List<Basket1> basketList = new ArrayList()
    Class Basket2 {
    public String color;
    pubic String type;
    public List<Basket2> basketList = new ArrayList()
    We need to exact copy Basket1 to Basket2. We are in trouble to copy List of child because we do not have how many child Basket1 have of same type..
    Can someone help us how we can implement such kind of complex object bidirectional one to many relationship??

    I can't see anything bidirectional about these relationships. What I can see is a couple of BasketN classes that look identical so I don't know why they both exist, and they both contain lists of themselves as members, which suggests some kind of tree structure. Nothing bidirectional there. I can see tat these things can form circular object graphs but I don't see why you would want to do that.
    We need to exact copy Basket1 to Basket2And I don't know what that means. Please explain.

  • How to insert data in a one-to-many relationship

    How do you insert data into the client, my model entity beans have a one-to-many relationship.
    PARENT ENTITY BEAN
    PARENT-ID
    PARENT-NAME
    The ejbCreate(Integer parentID,String name)
    CHILD ENTITY BEAN
    CHILD-ID
    CHILD-NAME
    PARENT-ID(foreign key of PARENTID).
    ejbCreate(Integer parentID,String name,String foreignparentID)
    In a jsp page i collect the parent details and 3 corresponding chld details in a text box.
    Can you please tell me how do i proceed from here...
    ie. how to i insert data into the entity beans..
    Do i pass the child as a collection, and within parents ejbCreate() method do i lookup for the childs home interface and insert one -by -one from the collection.
    1. Considering the above example, can some one pls tell how the ejbCreate() mehod signatures, for the parent and child entity beans should be.
    2. Pls also show some sample client code as to how to make an insertion.
    3. In case you are passing a collection of child data, then in what format does one have to insert into a collection and also how does the container know how to insert the values in the child table , bcoz we are passing as a collection.
    4.In case collections cannot be inserted do we need to iterate into the collection in parent's ejbCreate() method, and manually insert into the database of the childtable, thereby creating child entity beans.
    Thanks for your time and support...
    regards
    kartik

    Hi,
    3. In this case of course child's ejbCreate(and postCreate) looks like
    ejbCreate(Integer childID,String name,ParentLocal parent) {
    setId(Id);
    setName(name);
    ejbPostCreate(Integer childID,String name,ParentLocal parent) {
    setParent(parent);
    Here you don't need IDs, but it happens only using Locals, not Remotes, if I'm not wrong. Container does it itself.
    1. Of course, if you have parent.getChildren() and parent.setChildren() then you don't need any loops, but it should be done anyway in postCreate, because in ejbCreate there no parent exists yet.
    Once more 3: example - I'm using JBoss 3.2.5 as EJB container. It has tomcat inside and EJB and JSP+Struts use the same jvm. It means for me that I don't need to use remote interfaces, just locals. And in this case I can implement ejb-relations. So, a have the abstract method parent.getChildren() which returns Collection of ChildLocal - s and method parent.setChildren(Collection childrenLocals) which creates/modifies children by itself.
    I have not used remotes for a long time, but as I remember it was not possible to implement ejb-relations using remotes.
    regards,
    Gio

  • Struggling with a one to many relationship in a sub-report

    Post Author: Scott_tansley
    CA Forum: General
    I have a database schema as per below: tblENQUIRY                 tblDatasheets                  tblReportParasIRSID (PK)       1 --> &  IRSID (FK)                       UID (PK)Attribute1                     SHEETID (PK)     1 > &  SHEETID (FK)Attribute2                     Attribute1                         LIST_ORDER                         tblStandardParasAttribute3                     Attribute2                         PARA_CODE (FK)    & < 1   CODE     (PK)etc...                            Attribute3                                                                     TEXT                                   etc...
    The PROBLEM I am a Crystal Reports Newbie, and having to work through things bit by bitu2026  I've managed to achieve quite a lot, but I'm totally stuck with this and would appreciate some help. I need to create a report (essentially a letter and some datasheets) around a one-to-many relationship, which I have managed to compile using a main report (for the one &#91;tblENQUIRY&#93;) and sub report (for the many &#91;tblDatasheets&#93;).  Essentially I need a covering letter, then the u2018manyu2019 datasheets, and then a number of other pages (which are largely static text). I have created a main report which includes the covering letter, holds a subreport for the datasheets, and then contains the text for the additional pages.  This all works fine, and I get the correct number of datasheets for each main report. My problem stems from the use of this sub report.  This sub-report needs to hold some attribute values for each datasheet, which is fine.  However, on each datasheet page I need to have some paragraphs, which are held in another one to many relationship.  Each datasheet may have up to six paragraphs held as a code in tblReportParas, with a relationship to the text as held in tblStandardParas. My original thought would have been to embed another sub report, containing the values from tblStandardParas!TEXT, into the first sub report.  However, I have found that it is not possible to have a sub-report inside another sub-report.  I had seperated the first sub-report out from the main report, and then embedded another sub-report into it.  This worked fine until I tried to stitch the sub-report back into the main report (at which point the sub-sub-report dissapeared from view). I have therefore reworked my sub-report a little, and the attribution is now stored in a pageheader, with the tblStandardParas!TEXT in a detail section below it.  This almost works! The only problem is that there is no relationship between the pageheader and detail sections.  To clarify, I would expect to have one datasheet, with the attribution at the top, and then the six paras below.  Then, the same on the next page (assuming there is a second datasheet) for that report.  Instead, I get the correct attribution, but the detail section actually gives every paragraph in the database, no matter which datasheet/or report it related to!  I therefore need to limit the detail section to only show those paragraphs where the SHEETID in tblReportParas is the same as the tblDatasheets SHEETID. Any offers of advice would be appreciated.

    Post Author: Scott_tansley
    CA Forum: General
    I managed to resolve this myself in the end.  I moves the tblEnquiry data into report header/footer sections, this allowed me to add the tblDatasheets information into the details section, which gave me multiple pages - and then finally, the Paragraphs were added through the use of a sub report. 
    There's probably an even better way, but for now it works, it's quick - and so I'm going to go with it!
    Thanks for your interest.

  • How do I create a One to many relationship page in Dreamweaver?

    How do I create a page in dreamweaver that comes up after the user logs in from the log in page that will allow the user to:
    Add, change and delete in 2 tables that are in my MYSQL database that is a one to many relationship
    One thing that is confusing is how the foreign key that links to the one side of the relationship is created in the many side without the user inputting the foreign key each time adding information to the many side table.
    I am creating this in Dreamweaver using a MYSQL database and PHP.

    >Would the following be a part of it:
    >
    >Outer join
    Probably not. When updating/inserting/deleting from 2 tables you perform each seperately. Table updates may join two or more tables to resolve the correct row(s) but you still only update one table at a time. Procedurally you would create a transaction, update the first table, update the second table and then commit the transaction.
    EDIT: Well I take back my last comment. I see that MySQL does seem to support multiple table updates. I don't use MySQL so I can't really help you on that but the MySQL manual gives pretty clear syntax.

  • Aggregate one-to-many relationship problem

    Hello,
    After migrating from Toplink 9i I've stumbled across a problem with our aggregate objects.
    Toplink Workbench reports no errors and generates a nice XML but in runtime I get this error whenever a aggregate function is used.
    [TopLink fin]: 2008.02.13 03:18:11.552--ServerSession(12626425)--Connection(29948747)--Thread(Thread[main,5,main])--SELECT DISTINCT t0.NPL_PACK_ID, t0.NPL_ID FROM NPL_MEDPROD t3, FASS_MEDPROD t2, NPL_MEDPROD t1, NPL_PACKAGE t0 WHERE (((t0.NPL_ID = t1._Presentation->NPL_ID_IN_REFERENCE_NPL_PACKAGE_NPL_MEDPROD_Test) AND ((t1.NPL_ID = t2.NPL_ID) AND (t3.NPL_ID LIKE '19750613000031%'))) AND (t3.NPL_ID = t2.NPL_ID))
    Caused by: Undantag [TOPLINK-4002] (Oracle TopLink - 10g Release 3 (10.1.3.1.0) (Build 061004)): oracle.toplink.exceptions.DatabaseException
    Internt undantag: java.sql.SQLException: ORA-00911: invalid character
    Felkod: 911
    I belive that problem resides in this clause :
    t1._Presentation->NPL_ID_IN_REFERENCE_NPL_PACKAGE_NPL_MEDPROD_Test
    I've created a small test project with just a couple of classes but the same aggregate problem occurs which has let me to believe the problem does not come from the migrating process which was my first guess. If anyone could help me discover what I am doing wrong it would be very appreciated. Below is my test project output.
    <?xml version="1.0" encoding="UTF-8"?>
    <toplink:object-persistence version="Oracle TopLink - 10g Release 3 (10.1.3.1.0) (Build 061004)" xmlns:opm="http://xmlns.oracle.com/ias/xsds/opm" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:toplink="http://xmlns.oracle.com/ias/xsds/toplink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <opm:name>test</opm:name>
    <opm:class-mapping-descriptors>
    <opm:class-mapping-descriptor xsi:type="toplink:relational-class-mapping-descriptor">
    <opm:class>se.lif.fass.fassdata.impl.FASSMedProdImpl</opm:class>
    <opm:alias>FASSMedProdImpl</opm:alias>
    <opm:primary-key>
    <opm:field table="FASS_MEDPROD" name="NPL_ID" xsi:type="opm:column"/>
    </opm:primary-key>
    <opm:events xsi:type="toplink:event-policy"/>
    <opm:querying xsi:type="toplink:query-policy"/>
    <opm:attribute-mappings>
    <opm:attribute-mapping xsi:type="toplink:one-to-one-mapping">
    <opm:attribute-name>_Medprod</opm:attribute-name>
    <opm:reference-class>schemas_npl.instance.impl.MedprodTypeImpl</opm:reference-class>
    <opm:private-owned>true</opm:private-owned>
    <opm:foreign-key>
    <opm:field-reference>
    <opm:source-field table="FASS_MEDPROD" name="NPL_ID" xsi:type="opm:column"/>
    <opm:target-field table="NPL_MEDPROD" name="NPL_ID" xsi:type="opm:column"/>
    </opm:field-reference>
    </opm:foreign-key>
    <opm:foreign-key-fields>
    <opm:field table="FASS_MEDPROD" name="NPL_ID" xsi:type="opm:column"/>
    </opm:foreign-key-fields>
    <toplink:batch-reading>true</toplink:batch-reading>
    <toplink:selection-query xsi:type="toplink:read-object-query"/>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>id</opm:attribute-name>
    <opm:read-only>true</opm:read-only>
    <opm:field table="FASS_MEDPROD" name="NPL_ID" xsi:type="opm:column"/>
    </opm:attribute-mapping>
    </opm:attribute-mappings>
    <toplink:descriptor-type>independent</toplink:descriptor-type>
    <toplink:instantiation/>
    <toplink:copying xsi:type="toplink:instantiation-copy-policy"/>
    <toplink:change-policy xsi:type="toplink:deferred-detection-change-policy"/>
    <toplink:tables>
    <toplink:table name="FASS_MEDPROD"/>
    </toplink:tables>
    </opm:class-mapping-descriptor>
    <opm:class-mapping-descriptor xsi:type="toplink:relational-class-mapping-descriptor">
    <opm:class>schemas_npl.instance.impl.MedprodTypeImpl</opm:class>
    <opm:alias>MedprodTypeImpl</opm:alias>
    <opm:primary-key>
    <opm:field table="NPL_MEDPROD" name="NPL_ID" xsi:type="opm:column"/>
    </opm:primary-key>
    <opm:events xsi:type="toplink:event-policy"/>
    <opm:querying xsi:type="toplink:query-policy"/>
    <opm:attribute-mappings>
    <opm:attribute-mapping xsi:type="toplink:aggregate-object-mapping">
    <opm:attribute-name>_Medprodpack</opm:attribute-name>
    <toplink:reference-class>schemas_npl.instance.impl.MedprodTypeImpl$MedprodpackTypeImpl</toplink:reference-class>
    <toplink:allow-null>false</toplink:allow-null>
    <toplink:field-translations>
    <toplink:field-translation>
    <toplink:source-field name="_Presentation->NPL_ID_IN_REFERENCE_NPL_PACKAGE_NPL_MEDPROD_Test" xsi:type="opm:column"/>
    <toplink:target-field table="NPL_MEDPROD" name="NPL_ID" xsi:type="opm:column"/>
    </toplink:field-translation>
    </toplink:field-translations>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>_Nplid</opm:attribute-name>
    <opm:field table="NPL_MEDPROD" name="NPL_ID" xsi:type="opm:column"/>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>id</opm:attribute-name>
    <opm:read-only>true</opm:read-only>
    <opm:field table="NPL_MEDPROD" name="NPL_ID" xsi:type="opm:column"/>
    </opm:attribute-mapping>
    </opm:attribute-mappings>
    <toplink:descriptor-type>independent</toplink:descriptor-type>
    <toplink:instantiation/>
    <toplink:copying xsi:type="toplink:instantiation-copy-policy"/>
    <toplink:change-policy xsi:type="toplink:deferred-detection-change-policy"/>
    <toplink:tables>
    <toplink:table name="NPL_MEDPROD"/>
    </toplink:tables>
    </opm:class-mapping-descriptor>
    <opm:class-mapping-descriptor xsi:type="toplink:relational-class-mapping-descriptor">
    <opm:class>schemas_npl.instance.impl.MedprodTypeImpl$MedprodpackTypeImpl</opm:class>
    <opm:alias>MedprodTypeImpl$MedprodpackTypeImpl</opm:alias>
    <opm:events xsi:type="toplink:event-policy"/>
    <opm:querying xsi:type="toplink:query-policy"/>
    <opm:attribute-mappings>
    <opm:attribute-mapping xsi:type="toplink:one-to-many-mapping">
    <opm:attribute-name>_Presentation</opm:attribute-name>
    <opm:reference-class>schemas_npl.instance.impl.MedprodTypeImpl$MedprodpackTypeImpl$PresentationTypeImpl</opm:reference-class>
    <opm:private-owned>true</opm:private-owned>
    <opm:target-foreign-key>
    <opm:field-reference>
    <opm:source-field table="NPL_PACKAGE" name="NPL_ID" xsi:type="opm:column"/>
    <opm:target-field name="_Presentation->NPL_ID_IN_REFERENCE_NPL_PACKAGE_NPL_MEDPROD_Test" xsi:type="opm:column"/>
    </opm:field-reference>
    </opm:target-foreign-key>
    <toplink:batch-reading>true</toplink:batch-reading>
    <toplink:container xsi:type="toplink:list-container-policy">
    <toplink:collection-type>com.sun.xml.bind.util.ListImpl</toplink:collection-type>
    </toplink:container>
    <toplink:selection-query xsi:type="toplink:read-all-query">
    <toplink:container xsi:type="toplink:list-container-policy">
    <toplink:collection-type>com.sun.xml.bind.util.ListImpl</toplink:collection-type>
    </toplink:container>
    </toplink:selection-query>
    </opm:attribute-mapping>
    </opm:attribute-mappings>
    <toplink:descriptor-type>aggregate</toplink:descriptor-type>
    <toplink:instantiation/>
    <toplink:copying xsi:type="toplink:instantiation-copy-policy"/>
    <toplink:change-policy xsi:type="toplink:deferred-detection-change-policy"/>
    </opm:class-mapping-descriptor>
    <opm:class-mapping-descriptor xsi:type="toplink:relational-class-mapping-descriptor">
    <opm:class>schemas_npl.instance.impl.MedprodTypeImpl$MedprodpackTypeImpl$PresentationTypeImpl</opm:class>
    <opm:alias>MedprodTypeImpl$MedprodpackTypeImpl$PresentationTypeImpl</opm:alias>
    <opm:primary-key>
    <opm:field table="NPL_PACKAGE" name="NPL_PACK_ID" xsi:type="opm:column"/>
    </opm:primary-key>
    <opm:events xsi:type="toplink:event-policy"/>
    <opm:querying xsi:type="toplink:query-policy"/>
    <opm:attribute-mappings>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>_Nplpackid</opm:attribute-name>
    <opm:field table="NPL_PACKAGE" name="NPL_PACK_ID" xsi:type="opm:column"/>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:one-to-one-mapping">
    <opm:attribute-name>backref</opm:attribute-name>
    <opm:reference-class>schemas_npl.instance.impl.MedprodTypeImpl</opm:reference-class>
    <opm:foreign-key>
    <opm:field-reference>
    <opm:source-field table="NPL_PACKAGE" name="NPL_ID" xsi:type="opm:column"/>
    <opm:target-field table="NPL_MEDPROD" name="NPL_ID" xsi:type="opm:column"/>
    </opm:field-reference>
    </opm:foreign-key>
    <opm:foreign-key-fields>
    <opm:field table="NPL_PACKAGE" name="NPL_ID" xsi:type="opm:column"/>
    </opm:foreign-key-fields>
    <toplink:indirection xsi:type="toplink:value-holder-indirection-policy"/>
    <toplink:selection-query xsi:type="toplink:read-object-query"/>
    </opm:attribute-mapping>
    <opm:attribute-mapping xsi:type="toplink:direct-mapping">
    <opm:attribute-name>id</opm:attribute-name>
    <opm:read-only>true</opm:read-only>
    <opm:field table="NPL_PACKAGE" name="NPL_ID" xsi:type="opm:column"/>
    </opm:attribute-mapping>
    </opm:attribute-mappings>
    <toplink:descriptor-type>independent</toplink:descriptor-type>
    <toplink:instantiation/>
    <toplink:copying xsi:type="toplink:instantiation-copy-policy"/>
    <toplink:change-policy xsi:type="toplink:deferred-detection-change-policy"/>
    <toplink:tables>
    <toplink:table name="NPL_PACKAGE"/>
    </toplink:tables>
    </opm:class-mapping-descriptor>
    </opm:class-mapping-descriptors>
    <toplink:login xsi:type="toplink:database-login">
    <toplink:platform-class>oracle.toplink.platform.database.oracle.Oracle8Platform</toplink:platform-class>
    <toplink:user-name>fassadmin</toplink:user-name>
    <toplink:password>3CC3773C96563CA0C89634305615359CD62D1A19DF561D1E</toplink:password>
    <toplink:driver-class>oracle.jdbc.driver.OracleDriver</toplink:driver-class>
    <toplink:connection-url>jdbc:oracle:oci8:@DB2</toplink:connection-url>
    </toplink:login>
    </toplink:object-persistence>
    Regards
    /Jonas

    The issue is in the one-to-many mapping in the aggregate,
    <br>
    <opm:attribute-mapping xsi:type="toplink:one-to-many-mapping">
      <opm:attribute-name>_Presentation</opm:attribute-name>
      <opm:reference-class>schemas_npl.instance.impl.MedprodTypeImpl$MedprodpackTypeImpl$PresentationTypeImpl</opm:reference-class>
      <opm:private-owned>true</opm:private-owned>
      <opm:target-foreign-key>
        <opm:field-reference>
          <opm:source-field table="NPL_PACKAGE" name="NPL_ID" xsi:type="opm:column"/>
          <opm:target-field name="_Presentation->NPL_ID_IN_REFERENCE_NPL_PACKAGE_NPL_MEDPROD_Test" xsi:type="opm:column"/>
        </opm:field-reference>
      </opm:target-foreign-key>There is an issue with the Mapping Workbench and shared aggregates with one-to-many mappings and translating the foreign key fields. Did this work before, I would be surprized if it did, unless the 2.5 Builder was used?
    Anyway the easiest workaround is to either edit the XML and change the NPL_ID_IN_REFERENCE_NPL_PACKAGE_NPL_MEDPROD_Test column name to what it should be, or define a descriptor amendment method to define the one-to-many mapping with the correct field names.
    -- James : EclipseLink

  • Newbie: one to many relationship SQL error

    Greetings all-
    This is probably a slam dunk for you JDO experts. I'm a JDO newbie, working
    with an existing schema in MySQL. I have a one to many relationship between
    two tables:
    Table "company":
    Fields:
    company_id: int(11) -- primary key
    name : varchar(64)
    division : varchar(64)
    Table "company_products"
    Fields:
    company_id: int(11) -- foreign key to table company
    product_name: varchar(64)
    product_description: varchar(64)
    So, I created the corresponding classes:
    public class Company {
    private int companyID;
    private String company_name;
    private String division;
    // Array of CompanyProduct
    private ArrayList companyProducts;
    // .. methods omitted
    public class CompanyProduct {
    private int companyID;
    private String productName;
    private String productDesc;
    // Methods omitted
    Then I created the "package.jdo" file:
    <?xml version="1.0"?>
    <jdo>
    <package name="com.packexpo.db">
    <class name="Company">
    <extension vendor-name="tt" key="table" value="company"/>
    <extension vendor-name="tt" key="pk-column" value="company_id"/>
    <extension vendor-name="tt" key="lock-column" value="none"/>
    <extension vendor-name="tt" key="class-column" value="none"/>
    <field name="companyID">
    <extension vendor-name="tt" key="data-column" value="company_id"/>
    </field>
    <field name="name">
    <extension vendor-name="tt" key="data-column" value="name"/>
    <extension vendor-name="tt" key="column-length" value="64"/>
    </field>
    <field name="division">
    <extension vendor-name="tt" key="data-column" value="division"/>
    <extension vendor-name="tt" key="column-length" value="64"/>
    </field>
    <field name="companyProducts">
    <collection element-type="com.packexpo.db.CompanyProduct"/>
    <extension vendor-name="tt" key="inverse" value="companyID"/>
    </field>
    </class>
    <class name="CompanyProduct">
    <extension vendor-name="tt" key="table" value="company_product"/>
    <extension vendor-name="tt" key="pk-column" value="company_id"/>
    <extension vendor-name="tt" key="lock-column" value="none"/>
    <extension vendor-name="tt" key="class-column" value="none"/>
    <field name="companyID">
    <extension vendor-name="tt" key="data-column" value="company_id"/>
    </field>
    <field name="productName">
    <extension vendor-name="tt" key="data-column" value="product_name"/>
    <extension vendor-name="tt" key="column-length" value="64"/>
    </field>
    <field name="productDesc">
    <extension vendor-name="tt" key="data-column"
    value="product_description"/>
    <extension vendor-name="tt" key="column-length" value="64"/>
    </field>
    </class>
    </package>
    </jdo>
    Enhancement works fine. I successfully query and retrive Company objects
    from the database, but as soon as I try to get the list of CompanyProducts,
    I get an SQL Error:
    javax.jdo.JDODataStoreException: [SQL=SELECT company.COMPANYPRODUCTSX FROM
    company WHERE company.company_id = 82061]
    E0610 Error in executeQuery()
    E0606 executeQuery() error --
    E0701 Error in getResult().
    E0708 Command results in error - 1054 Unknown column
    'company.COMPANYPRODUCTSX' in 'field list'
    NestedThrowables:
    com.solarmetric.kodo.impl.jdbc.sql.SQLExceptionWrapper: [SQL=SELECT
    company.COMPANYPRODUCTSX FROM company WHERE company.company_id = 82061]
    E0610 Error in executeQuery()
    E0606 executeQuery() error --
    E0701 Error in getResult().
    E0708 Command results in error - 1054 Unknown column
    'company.COMPANYPRODUCTSX' in 'field list'
    I know i have probably set up the package.jdo file incorrectly, but I'm at a
    loss for what I did wrong.
    Any suggestions?
    Thanks!
    -Mike

    Hi,
    915766 wrote:
    I need to write sql for below requirement:
    table structure is
    serial no LPN
    1 4
    2 4
    3 6
    4 6
    5 6
    6 3
    7 3
    8 3
    9 1
    I have to pick distinct 'LPN' like below:That sounds like a job for "GROUP BY lpn".
    (any serial no can be picked for the distinct LPN)It looks like you're displaying the lowest serial_no for each lpn. That's easy to do, using the aggregate MIN function.
    results needs to be as below:
    serial no LPN
    1 4
    3 6
    6 3
    9 1
    Please suggest with sql.Here's one way:
    SELECT    MIN (serial_no)   AS serial_no
    ,         lpn
    FROM      table_x
    GROUP BY  lpn
    ORDER BY  lpn     -- if wanted
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ {message:id=9360002}

  • Summarizing data in a one-to-many relationship

    Post Author: Bob Amiral
    CA Forum: General
    I use an order tracking system that has a one to many relationship between the main order information file and the line items file.  For each order, there can be one or more items in the items file.  I am having no luck trying to summarize data in such a way that shows selected information from the order file with only a summary from the item file on one line.  Instead, the reports expands by adding a line for each and every entry from the item file that relates to the order.
    How can I summarize data from the item file to show only one line of item data in the same line as the order data?

    Post Author: Charliy
    CA Forum: General
    Group by Order #
    Suppress the Detail (and possibly the Group Header, depending on how you want it to look)
    Put Running Totals in the Group Footer that reset on change of group.

  • One-to-many relationship: problem with several tables on the one side...

    Hello
    I'm having problems developing a database for a content management system. Apart from details, I've got one main table, that holds the tree structure of the content ("resources") and several other tables that contain data of a particular datatype ("documents", "images", etc.). Now, there's one-to-many relationship between "resources" table and all the datatype tables - that is, in the "resources" table there's "resource_id" column, being a foreign key referenced to the "id" columns in the datatype tables.
    The problem is that this design is deficient. I can't tell form the "resource_id" column from which datatype table to get the data. It seems to me that one-to-many relationship only works with two tables. If the data on the one side of the relationship is contained in several tables, problems arise.
    Anybody knows a solution? I would be obliged.
    Regards
    Havocado

    Hi;
    A simple way may be create a view on referenced tables:
    Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
    Connected as hr
    SQL>
    SQL> drop table resources;
    Table dropped
    SQL> create table resources(id number, name varchar2(12));
    Table created
    SQL> insert into resources values(1,'Doc....');
    1 row inserted
    SQL> insert into resources values(2,'Img....');
    1 row inserted
    SQL> drop table documents;
    Table dropped
    SQL> create table documents(id number, resource_id number,type varchar2(12));
    Table created
    SQL> insert into documents values(1,1,'txt');
    1 row inserted
    SQL> drop table images;
    Table dropped
    SQL> create table images(id number, resource_id number,path varchar2(24));
    Table created
    SQL> insert into images values(1,2,'/data01/images/img01.jpg');
    1 row inserted
    SQL> create or replace view vw_resource_ref as
      2    select id, resource_id, type, null as path from documents
      3      union
      4     select id, resource_id, null as type, path from images;
    View created
    SQL> select * from resources r inner join vw_resource_ref rv on r.id = rv.resource_id;
            ID NAME                 ID RESOURCE_ID TYPE         PATH
             1 Doc....               1           1 txt         
             2 Img....               1           2              /data01/images/img01.jpg
    SQL> Regards....

Maybe you are looking for

  • Apple Mobile Device Service has stopped working. Vista SP2, iTunes 10.5

    Hi there. I've been having an issue syncing my iPhone to iTunes. Here's a description of the problem: -With an up-to-date Apple Mobile Device Service, error windows constantly pop-up saying that it has stopped working. If I close the error window, an

  • PHP  and Oracle Connection

    Please help to connect to oracle through php. OS=Windows Server 2008 R2(x64)= is working correctly PHP ver=PHP 5.3.2= is working correctly ORACLE = Oracle Database 11gR2= is working correctly Since the PHP and Oracle on the same machine, I did not in

  • Setup to replicate update/insert and not delete

    Currently what I am looking to do is setup streams to do a one way replication of only updates and inserts but not include deteles. I've only done the most basic searches through the Oracle documentation, but as I read the 10.2G pdfs so far it seems

  • Calc Manager Error "Could Not Connect To Dimension Server"

    Could not connect to Dimension Server. Please make sure that the required services are started. https://ServerName:19443/HyperionPlanning/servlet/HspAppManagerServlet: Connection refused: connect. Hyperion Planning - 11.1.2.3 can anyone help me. Than

  • Performance issue in mysap SRM

    Hi, We are facing the performance issue in mySAP SRM system. User when logs onto mySAP SRM and confirms a purchase order it takes a very long duration. Can you please suggest as to how to analyze the performance issue. Do we have anything similar to