Inserting with many to many relationship

db and dev 10g rel2 ,
hi all ,
an application for a laboratory ,( patients and tests)
i think the relation here is (many to many) , because each patient can have multiple tests, and each test can
have multiple patients .
what tables should i create ?
and finally i should have a block to insert data for patients , and it should have
the name of the patient and the test he is doing .
so what tables should i create , and the block for the data entry will be based on which table ? or tables ?
thanks a lot

Hi
First i do strongly recommend collecting reports & forms papers which r filled out by Mrs employees & patients then u stay to decide by ur pen & formalize what r the data required & what type of relationship need to be contracted from scratch off course many modifications Will occure by it Will be easier to modify on papers.
Then my guess is u.Will need tables for employees , Patients ,Labs & Analysis Types
Employees & Patients fields in a table r common in ;name, id,address,birthday or age ,
etc.
Labs table is needed if only u have many labs types ...
Analysis Types table is listing...
Analysis_id , Analysis_name& comments if any...
Actual_Analysis table which Will have many pk is from all previous tables e.g.
employees_id,Analysis_id, Patient_id,Lab no
,Analysis_date,Delivery_date,
Analysis time , Delivery or due time.
Status +-- A flag Which indicates ethe delivery status done or not
Deposit
way payment -- can have a table for it.
total cost
taxes
etc.
--========
All payments affairs could have a table or more for it
hope it.helps as a start.
Amatu Allah

Similar Messages

  • About inserting with one to many relationship

    db and dev 10g rel2 ,
    hi all ,
    using emp and dept tables of scott/tiger schema .
    if i have a form , how can i insert 4 new employees in a specific dept ? what blocks should i build , and how can the user inserts into these blocks ?
    thanks in advance

    the user should write "20" in the deptno field once , and write the 4 new employees' data .To do this, you create a relationship between the blocks with the Dept block to be the Master and the Emp block to be the detail block. Your Form layout would look something like the following:
    |---------------------------------------|
    | [     ] Department Number             |
    |---------------------------------------|
    | Employee data...                      |
    | [    ] Emp ID                         |
    | [               ] First Name          |
    | ...rest of the columns listed here... |
    |---------------------------------------|Once you have created the relationship, Forms will handle the rest. Just run your form, select department 20 and start adding new employees.
    Craig...

  • Insert with one-to-many mapping

    Hi,
    I've got the following situation:
    - an object A with a vector of object B
    - I defined a one-to-many relation in the descriptor of A referencing a collection of B using indirection through valueHolderInterface, the "private owned" is also checked
    - I defined a one-to-one relation in the descriptor of B referencing the object A using indirection through valueHolderInterface
    - the bidirectional relationship is maintained.
    I try to insert a new object A with a new object B inside. The code is as follows:
    A = new A();
    B = new B();
    // ... set the A attribute values
    // ... set the B attribute values
    A.addB(B);
    UnitOfWork uow = session.acquireUnitOfWork();
    uow.registerNewObject(A);
    uow.commit();
    where addB(b) is as follows:
    ((java.util.Vector)bvector.getValue()).add(b);
    b.setA(this);
    Executing this code, the object A is inserted in the database but the object B is not. And I would like that the object B is also stored in the database. Do I really have to register it? I want to make the insert in just one transaction. Have anyone an idea? I tried a lot of different configurations and just one SQL insert order is generated by Toplink.
    Thanks,
    Frédéric

    Hi Don,
    This is with reference to your comments on the following oracel forum query "http://forums.oracle.com/forums/thread.jspa?messageID=508819��" regarding 1:M mapping insertion problem.(Same one)
    Actually I also have the same kind of scenario but the data in not getting inserted to the detail table. It always gives ORA-1400 error as it is unable to populate the foreign key of parent in child table.
    Can you suggest if I am missing something.
    Your quick response will be appreciated.
    Message was edited by:
    user466708

  • Working with many-to-many relationships

    I am about to start my first experience with many-to-many
    relationships using PHP and MySQL.
    My project is to create an events registration form. As you
    know, there can be many events and many participants attending many
    events.
    I am not sure on how to structure my database and tables so I
    will first show you what I have:
    create table programs (
    program_id int not null primary key auto_increment,
    program_name varchar(100) not null,
    program_date varchar(25) not null,
    program_time varchar(25) not null,
    program_coordinator varchar(100),
    program_seats int not null
    create table participants (
    participant_id int not null primary key auto_increment,
    participant_name varchar(100) not null,
    participant_phone varchar(12) not null
    I know that I need a middle table to join the two.
    create table programs_participants (
    program_id int references program(id),
    participants_id int references participants(id),
    primary key (program_id, participants_id)
    My problem is, how do I submit to both the participants AND
    the programs_participants table together? Or is this not possible?
    The participants are not already in the database when we register
    them. We enter their personal info and select their desired events
    from checkboxes on the same page.
    Thanks for your help.

    > My problem is, how do I submit to both the participants
    AND the
    > programs_participants table together? Or is this not
    possible? The
    > participants are not already in the database when we
    register them. We
    > enter
    > their personal info and select their desired events from
    checkboxes on the
    > same
    > page.
    What you need to do is a multi-step insert.
    First, you insert the new participant into the participant
    table, then use
    the @@identity command to get the uniqueID of that newly
    entered record.
    Then you can take that uniqueID to build the entry for the
    programs_participants table.
    If you use a stored procedure, you should be able to do all
    of that with
    only having to create one call to the DB from your
    Application.
    _Darrel

  • Hierarchical query with many-to-many relationship

    I have read with interest the creative solutions to complex hierarchical queries posted previously; they have been instructive but have not quite addressed this scenario.
    We have a hierarchy table H, with columns for ID, name, parentID, and other attributes.
    Within this table are a number of independent hierarchies, each existing for a different purpose.
    We have a master list of hierarchies in table T which describes the purpose of each hierarchy, provides some default attributes which the nodes can inherit, and stores a unique id for each hierarchy and a pointer to the root node of the corresponding hierarchy in table H.
    We have a master list of items M, with identically named columns to those in H, along with many other attributes.
    The members of table M ALL belong to EACH of the Hierarchies. So we have a link table I to define the intersection of H and M.
    So the leaf nodes of H are really containers for the list of elements from M which may be attached to them.
    The universe of M is very volatile, with new members being added, old ones deleted, and existing ones being reclassified frequently from node to node within each hierarchy. Since the hierarchies have to be built to handle every possible scenario, so that the members of M can always find a suitable node to reside in, quite often, in fact more often than not, the majority of leaf nodes for each hierarchy are empty at any given moment.
    Therefore, although we always know the root sector of a given hierarchy and can traverse downwards from there, if we worked our way up from the intersection table, we could eliminate up to 70% of the nodes of any given hierarchy from further consideration, as they don't need to be (in fact, must not be) included in reports.
    As implied by the above, rows in M are structurally similar (in terms of columns, but not in any real world sense) and are a superset of rows in H. But combining them into the one table doesn't seem to help the reporting process due to the many-to-many relationship which prevents the ID/parentID relationship from being carried through to this level.
    There are a number of other considerations of which the most pertinent is that the people using this database generally have an interest in only a subset of the master list of items in M. This relationship is also dynamic but important enough and rigid enough that another link table P exists to combine the Users in table U with the subset of M in which they are interested. (The users are also grouped into hierarchies of a totally different nature, but this aspect is secondary for now.)
    The reporting is reasonably straightforward for any single combination of User and Hierarchy; they want to see all the items they are interested in, listed in hierarchical sequence, totalled on change of level with the individual items M listed beneath the nodes of H. This is unfortunately required in real time, so retrieval performance is paramount.
    Some statistics might help to determine the optimum approach:
    The largest hierarchy has 10,000 nodes. The smallest about 100.
    The largest would have 70% or more of its nodes unused at any point in time, and even the smallest would have 25% unused.
    The hierarchies tend to be broad rather than deep, the maximum number of levels being about 5; but the larger ones should be twice as deep as this if performance was not compromised.
    There are dozens of hierarchies, but it may be possible to sharply reduce this number by exploiting the Order Siblings By clause.
    The number of rows in M varies between 500,000 and 50,000; depending upon how long historical data is retained on-line (and performance permitting, it would be retained indefinitely).
    The number of users varies between 1000 and 2000 but the range of M in which they are interested varies greatly; from as few as 100 to as many as 10,000+. So it is almost always worth beginning by eliminating the items in which they are not interested, implying once again that the hierarchy should be traversed upwards rather than down from the root.
    The current system is very old and survives by a tactic of building what are essentially materialised views of the database structure for each user overnight using, ahem, non-relational technology. This is inefficient and not easily scaled (but it works) and hence this redevelopment project needs to (a) work, and (b) work better and faster.
    I am happy to provide some DDL scripts if that helps explain the problem better than this narrative.
    I can't help feeling that the solution lies in somehow extending the hierarchical query past the many-to-many link table so that the Master list can be merged directly into the hierarchy such that the M items become the leaf nodes rather than the design outlined above - but I don't know how to do that. But I am sure everyone reading this does! :)
    All advice appreciated. Database version is not an issue; we are currently using version 10XE for experimentation, but production usage could be on 11 if that contains helpful features.
    Thank you
    CS

    Hi,
    ChrisS. wrote:
    I am happy to provide some DDL scripts if that helps explain the problem better than this narrative.Yes, please do.
    The problem seems interesting, I'm sure many people here (including myself) are willing to help you in this matter.
    So yes, post DDL for the tables, as well as INSERTs to populate them with representative data. Please also include the output you require along with detailed explanations about the logic to get it.
    Don't forget to put lines of code between {code} tags in order to preserve formatting and readability, like this :
    SELECT sysdate FROM dual;Thanks.

  • Defining a many-to-many relationship with CMP EJBs  : does it work for you

    Curious to know whether someone has been able to set up a many to many relationship between two entity beans.
    I have been struggling with this for days now and I can't get it to work.
    In my test project I have two entity beans, resp. Consultant and Solution.
    Consultant has a cmr field called 'solutions', which is a collection object from the opposite side (Solution).
    This is the source of the ejb-jar.xml file
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
    <ejb-jar>
         <description>EJB JAR description</description>
         <display-name>EJB JAR</display-name>
         <enterprise-beans>
              <session>
                   <ejb-name>ProfilerBean</ejb-name>
                   <home>com.atosorigin.tcc.testing.ejbses.profiling.ProfilerHome</home>
                   <remote>com.atosorigin.tcc.testing.ejbses.profiling.Profiler</remote>
                   <local-home>com.atosorigin.tcc.testing.ejbses.profiling.ProfilerLocalHome</local-home>
                   <local>com.atosorigin.tcc.testing.ejbses.profiling.ProfilerLocal</local>
                   <ejb-class>com.atosorigin.tcc.testing.ejbses.profiling.ProfilerBean</ejb-class>
                   <session-type>Stateless</session-type>
                   <transaction-type>Container</transaction-type>
                   <ejb-local-ref>
                        <ejb-ref-name>EJBTesting/Solution</ejb-ref-name>
                        <ejb-ref-type>Entity</ejb-ref-type>
                        <local-home>com.atosorigin.tcc.testing.ejbcmp.profiling.SolutionLocalHome</local-home>
                        <local>com.atosorigin.tcc.testing.ejbcmp.profiling.SolutionLocal</local>
                        <ejb-link>SolutionBean</ejb-link>
                   </ejb-local-ref>
                   <ejb-local-ref>
                        <ejb-ref-name>EJBTesting/Consultant</ejb-ref-name>
                        <ejb-ref-type>Entity</ejb-ref-type>
                        <local-home>com.atosorigin.tcc.testing.ejbcmp.profiling.ConsultantLocalHome</local-home>
                        <local>com.atosorigin.tcc.testing.ejbcmp.profiling.ConsultantLocal</local>
                        <ejb-link>ConsultantBean</ejb-link>
                   </ejb-local-ref>
              </session>
              <entity>
                   <ejb-name>ConsultantBean</ejb-name>
                   <home>com.atosorigin.tcc.testing.ejbcmp.profiling.ConsultantHome</home>
                   <remote>com.atosorigin.tcc.testing.ejbcmp.profiling.Consultant</remote>
                   <local-home>com.atosorigin.tcc.testing.ejbcmp.profiling.ConsultantLocalHome</local-home>
                   <local>com.atosorigin.tcc.testing.ejbcmp.profiling.ConsultantLocal</local>
                   <ejb-class>com.atosorigin.tcc.testing.ejbcmp.profiling.ConsultantBean</ejb-class>
                   <persistence-type>Container</persistence-type>
                   <prim-key-class>java.lang.String</prim-key-class>
                   <reentrant>False</reentrant>
                   <cmp-version>2.x</cmp-version>
                   <abstract-schema-name>Consultant</abstract-schema-name>
                   <cmp-field>
                        <field-name>firstname</field-name>
                   </cmp-field>
                   <cmp-field>
                        <field-name>lastname</field-name>
                   </cmp-field>
                   <cmp-field>
                        <field-name>country</field-name>
                   </cmp-field>
                   <cmp-field>
                        <field-name>id</field-name>
                   </cmp-field>
                   <primkey-field>id</primkey-field>
                   <query>
                        <query-method>
                             <method-name>findBySolution</method-name>
                             <method-params>
                                  <method-param>java.lang.String</method-param>
                             </method-params>
                        </query-method>
                        <ejb-ql>SELECT Object(c) FROM Consultant AS c,
                        IN(c.solutions) s WHERE s.id = ?1 </ejb-ql>
                   </query>
              </entity>
              <entity>
                   <ejb-name>SolutionBean</ejb-name>
                   <home>com.atosorigin.tcc.testing.ejbcmp.profiling.SolutionHome</home>
                   <remote>com.atosorigin.tcc.testing.ejbcmp.profiling.Solution</remote>
                   <local-home>com.atosorigin.tcc.testing.ejbcmp.profiling.SolutionLocalHome</local-home>
                   <local>com.atosorigin.tcc.testing.ejbcmp.profiling.SolutionLocal</local>
                   <ejb-class>com.atosorigin.tcc.testing.ejbcmp.profiling.SolutionBean</ejb-class>
                   <persistence-type>Container</persistence-type>
                   <prim-key-class>java.lang.String</prim-key-class>
                   <reentrant>False</reentrant>
                   <cmp-version>2.x</cmp-version>
                   <abstract-schema-name>Solution</abstract-schema-name>
                   <cmp-field>
                        <field-name>description</field-name>
                   </cmp-field>
                   <cmp-field>
                        <field-name>name</field-name>
                   </cmp-field>
                   <cmp-field>
                        <field-name>parent</field-name>
                   </cmp-field>
                   <cmp-field>
                        <field-name>id</field-name>
                   </cmp-field>
                   <primkey-field>id</primkey-field>
                   <query>
                        <query-method>
                             <method-name>findChildSolutions</method-name>
                             <method-params>
                                  <method-param>java.lang.String</method-param>
                             </method-params>
                        </query-method>
                        <ejb-ql>SELECT Object(s) FROM Solution AS s WHERE
                        s.parent = ?1</ejb-ql>
                   </query>
                   <query>
                        <query-method>
                             <method-name>findTopLevelSolutions</method-name>
                             <method-params/>
                        </query-method>
                        <ejb-ql>Select Object(s) FROM Solution AS s WHERE
                        (s.parent = &apos;none&apos;)</ejb-ql>
                   </query>
              </entity>
         </enterprise-beans>
         <relationships>
              <ejb-relation>
                   <description>A consultant may have one or more areas of expertise</description>
                   <ejb-relation-name>Consultant_Solutions</ejb-relation-name>
                   <ejb-relationship-role>
                        <ejb-relationship-role-name>com.atosorigin.tcc.testing.ejbcmp.profiling.ConsultantBean</ejb-relationship-role-name>
                        <multiplicity>Many</multiplicity>
                        <relationship-role-source>
                             <ejb-name>ConsultantBean</ejb-name>
                        </relationship-role-source>
                        <cmr-field>
                             <cmr-field-name>solutions</cmr-field-name>
                             <cmr-field-type>java.util.Collection</cmr-field-type>
                        </cmr-field>
                   </ejb-relationship-role>
                   <ejb-relationship-role>
                        <ejb-relationship-role-name>com.atosorigin.tcc.testing.ejbcmp.profiling.SolutionBean</ejb-relationship-role-name>
                        <multiplicity>Many</multiplicity>
                        <relationship-role-source>
                             <ejb-name>SolutionBean</ejb-name>
                        </relationship-role-source>
                   </ejb-relationship-role>
              </ejb-relation>
         </relationships>
         <assembly-descriptor>
              <container-transaction>
                   <description>container-transaction</description>
                   <method>
                        <ejb-name>SolutionBean</ejb-name>
                        <method-name>*</method-name>
                   </method>
                   <method>
                        <ejb-name>ProfilerBean</ejb-name>
                        <method-name>*</method-name>
                   </method>
                   <method>
                        <ejb-name>ConsultantBean</ejb-name>
                        <method-name>*</method-name>
                   </method>
                   <trans-attribute>Required</trans-attribute>
              </container-transaction>
         </assembly-descriptor>
    </ejb-jar>
    I created a stateless session bean as a business facade for the two entity beans. I then created a webservice to test the beans.
    What works :
    - create a consultant
    - get a consultant
    - create a solution
    - get a solution
    (basically everything that doesn't involve the relationship field.
    However, what doesn't work is the method call assignSolution:
    - assign solution : this is implemented as follows
    Business Method.
         public void assignSolution(String consultantID, String solutionID)
              throws ProfilingException {
              // TODO : Implement
              ConsultantLocal cons = null;
              SolutionLocal sol = null;
              try {
                   cons = consHome.findByPrimaryKey(consultantID);
                   sol = solHome.findByPrimaryKey(solutionID);
                   Collection solutions = cons.getSolutions();
                   solutions.add(sol);
                   //sol.getConsultants().add(cons);
              } catch (FinderException ex) {
                   ex.printStackTrace();
                   throw new ProfilingException("failed to retrieve data from DB", ex);
    As you can see I am trying to use the CM Relationship in this methhod. Adding the solution to a consultant should be as simple as adding a solution object to the collection retrieved with the getSolutions accessor. The Container is expected to persist the information in my MAXDB database.
    However this doesn't happen.
    The ORM details as defined in the persistent.xml follows :
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE persistent-ejb-map SYSTEM "persistent.dtd">
    <persistent-ejb-map>
         <locking
              type="Table"/>
         <db-properties>
              <data-source-name>TCC_PORTAL_PROFILER</data-source-name>
              <database-vendor
                   name="SAPDB"/>
         </db-properties>
         <entity-beans>
              <entity-bean>
                   <ejb-name>ConsultantBean</ejb-name>
                   <table-name>PFL_CONSULTANTS</table-name>
                   <field-map
                        key-type="NoKey">
                        <field-name>firstname</field-name>
                        <column>
                             <column-name>FIRSTNAME</column-name>
                        </column>
                   </field-map>
                   <field-map
                        key-type="NoKey">
                        <field-name>lastname</field-name>
                        <column>
                             <column-name>LASTNAME</column-name>
                        </column>
                   </field-map>
                   <field-map
                        key-type="NoKey">
                        <field-name>country</field-name>
                        <column>
                             <column-name>COUNTRY</column-name>
                        </column>
                   </field-map>
                   <field-map
                        key-type="PrimaryKey">
                        <field-name>id</field-name>
                        <column>
                             <column-name>ID</column-name>
                        </column>
                   </field-map>
                   <finder-descriptor>
                        <method-name>findBySolution</method-name>
                        <method-params>
                             <method-param>java.lang.String</method-param>
                        </method-params>
                        <load-selected-objects
                             lock="read"/>
                   </finder-descriptor>
              </entity-bean>
              <entity-bean>
                   <ejb-name>SolutionBean</ejb-name>
                   <table-name>PFL_SAPSOLUTIONS</table-name>
                   <field-map
                        key-type="NoKey">
                        <field-name>description</field-name>
                        <column>
                             <column-name>DESCRIPTION</column-name>
                        </column>
                   </field-map>
                   <field-map
                        key-type="NoKey">
                        <field-name>name</field-name>
                        <column>
                             <column-name>NAME</column-name>
                        </column>
                   </field-map>
                   <field-map
                        key-type="NoKey">
                        <field-name>parent</field-name>
                        <column>
                             <column-name>PARENTID</column-name>
                        </column>
                   </field-map>
                   <field-map
                        key-type="PrimaryKey">
                        <field-name>id</field-name>
                        <column>
                             <column-name>ID</column-name>
                        </column>
                   </field-map>
                   <finder-descriptor>
                        <method-name>findChildSolutions</method-name>
                        <method-params>
                             <method-param>java.lang.String</method-param>
                        </method-params>
                        <load-selected-objects
                             lock="read"/>
                   </finder-descriptor>
                   <finder-descriptor>
                        <method-name>findTopLevelSolutions</method-name>
                        <method-params/>
                        <load-selected-objects
                             lock="read"/>
                   </finder-descriptor>
              </entity-bean>
         </entity-beans>
         <relationships>
              <table-relation>
                   <help-table>PFL_CONS_SOL_MAP</help-table>
                   <table-relationship-role
                        key-type="PrimaryKey">
                        <ejb-name>ConsultantBean</ejb-name>
                        <cmr-field>solutions</cmr-field>
                        <fk-column>
                             <column-name>CONSULTANTID</column-name>
                             <pk-field-name>id</pk-field-name>
                        </fk-column>
                   </table-relationship-role>
                   <table-relationship-role
                        key-type="PrimaryKey">
                        <ejb-name>SolutionBean</ejb-name>
                        <fk-column>
                             <column-name>SOLUTIONID</column-name>
                             <pk-field-name>id</pk-field-name>
                        </fk-column>
                   </table-relationship-role>
              </table-relation>
         </relationships>
    </persistent-ejb-map>
    The error in the default trace file when calling the method states, there is an "inconsistency in the number of primary keys". Details follow.
    #1.5#000F1F188E5C004400000000000010480003E76C80EFD57A#1098880364327#com.sap.engine.services.ejb#com.atosorigin.tcc/EJBCMPProfilingTest#com.sap.engine.services.ejb#Guest#2####4d2b2370281411d9a40d000f1f188e5c#SAPEngine_Application_Thread[impl:3]_31##0#0#Error##Java###
    [EXCEPTION]
    #1#com.sap.engine.services.ejb.exceptions.BaseRemoteException: Exception in method assignSolution.
         at com.atosorigin.tcc.testing.ejbses.profiling.ProfilerObjectImpl0.assignSolution(ProfilerObjectImpl0.java:822)
         at com.atosorigin.tcc.testing.ejbses.profiling.Profiler_Stub.assignSolution(Profiler_Stub.java:533)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at com.sap.engine.services.ejb.session.stateless_sp5.ObjectStubProxyImpl.invoke(ObjectStubProxyImpl.java:187)
         at $Proxy73.assignSolution(Unknown Source)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:324)
         at com.sap.engine.services.webservices.runtime.EJBImplementationContainer.invokeMethod(EJBImplementationContainer.java:126)
         at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:146)
         at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:68)
         at com.sap.engine.services.webservices.runtime.servlet.ServletDispatcherImpl.doPost(ServletDispatcherImpl.java:92)
         at SoapServlet.doPost(SoapServlet.java:51)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:385)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:263)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:339)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:317)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:810)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:238)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:147)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37)
         at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:162)
    Caused by: com.sap.engine.services.applocking.exception.SAPAppLockingIllegalArgumentException: Inconsistency in number of primary keys
         at com.sap.engine.services.applocking.TableLockingImpl.getArgument(TableLockingImpl.java:385)
         at com.sap.engine.services.applocking.TableLockingImpl.lock(TableLockingImpl.java:128)
         at com.sap.engine.services.applocking.TableLockingImpl.lock(TableLockingImpl.java:138)
         at com.sap.engine.services.ejb.entity.pm.lock.TableLockingSystem.write(TableLockingSystem.java:82)
         at com.sap.engine.services.ejb.entity.pm.PersistentM2M.create(PersistentM2M.java:172)
         at com.sap.engine.services.ejb.entity.pm.PersistentCacheM2M.add(PersistentCacheM2M.java:197)
         at com.sap.engine.services.ejb.entity.pm.multiple.CollectionM2M.add(CollectionM2M.java:57)
         at com.atosorigin.tcc.testing.ejbses.profiling.ProfilerBean.assignSolution(ProfilerBean.java:201)
         at com.atosorigin.tcc.testing.ejbses.profiling.ProfilerObjectImpl0.assignSolution(ProfilerObjectImpl0.java:771)
         ... 32 more
    I can't figure out what the problem is with the ORM mapping defined.
    On the database level I have three tables. Consultant maps to PFL_CONSULTANT, Solution to PFL_SAPSOLUTIONS. The third table PFL_CONS_SOL_MAP is the help table used for the relationship (having two fields, which are in fact foreign keys from the other two tables to express the assignment of solutions to consultants (where a consultant can have one or more solutions).
    ps. : I am running Netweaver Developer Workplace (Netweaver 2004, at stack level 5)
    Message was edited by: Theo Paesen

    Hm, after disabling 'automatic locking' it works.

  • Urgent: Many to many relationship with Objects

    create type c1 as object (id varchar2(5),
    descr varchar2(200))
    create table c1_otab of c1(id primary key) object id primary key;
    create type c2 as object (id varchar2(5), descr varchar2(200), cat1 ref c1)
    I want a many to many relation between c1 and c2.
    How do I create an object table of c2 having id,cat1.id as primary key?
    Thanks

    Mina,
    As with relational tables, you can create a third table that has 1-n relationship with these two object tables. With 'cat1' as a REF attribute, an instance of c2 in c2_otab points to a c1 instance in c1_otab through the OID column. There is no need to explicitly create primary/foreign key. In fact, to prevent dangling REFs, the REF column should be declared as foreign key pointing to c1_otab.id (i.e. the primary key).
    Regards,
    Geoff
    create type c1 as object (id varchar2(5),
    descr varchar2(200))
    create table c1_otab of c1(id primary key) object id primary key;
    create type c2 as object (id varchar2(5), descr varchar2(200), cat1 ref c1)
    I want a many to many relation between c1 and c2.
    How do I create an object table of c2 having id,cat1.id as primary key?
    Thanks

  • Many-to-many relationship with value?

    An Order has many Item, each Item can belong in many Order.  This is a many-to-many relationship.
    However, if the Item has a defaultPrice, and an Order can optionally override the price of an Item.  How do I do that in ORM?
    In SQL, I'd have a link table that has two FK's OrderID & ItemID as composit PK, and have an additional OverridePrice column.
    How do I do that in ORM with only CFC annotation? if not, how about custom hibernate xml?
    Thanks.

    I'd probably treat it more like a one to many between order and order_item, and a one to many between item and order_item, rather than trying to treat it purely as a many-to-many between order and item.  In a many-to-many, the link table is purely that: a link table.  It would not have significant data, whereas you have a requirement for such data.
    That said, I reached this conclusion after only about 15sec of mulling it over, so there's likely to be other approaches too!
    Adam

  • QUESTION:  HOW TO WRITE QUERY  WITH MANY TO MANY RELATIONSHIPS

    Could someone help me out here?
    I was sitting here looking at some tables ie table_name and synonyms and wondering.
    If a table can belong to many synonyms and a synonym can belong to many tables how would one write a query where I would like to know which tables belong to each synonym or on the other hand which synonym belongs to what tables?
    Would I try to develop an outside join for this, a corrolated query or a query with a subquery or would there be another format that would work better?
    What would be the best method of attack on this?
    Thanks for your thoughts on this.
    al

    Actually, the relationship is not many to many. A table can have many synonyms, but a synonym within a namespace (i.e. a PUBLIC synonym, or a private synonym created by a user) can only point to one table. The xxx_synonmys tables already contain the information about the table_name and table_owner.
    John

  • How to create query for tables with many to many relationship

    in my sql i'm unable to update the table using select clause...is there any way to update a table which is in many to many relationship.
    Ex:1st table student(student_id int primary key auto_increment, student_name varchar(30));
    2nd table contact (contact_id int primary key auto_increment, c_email varchar(40));
    3rd table student_contact(student_id int references student, contact_id int references contact);
    i would like to auto insert the both two columns in the student_contact while the student and the contact table being updated automatically.

    This is a JSP/JSTL forum, not a SQL forum. If you're using MySQL, better use their own forums at dev.mysql.com.
    I'll give some hints anyway: learn about SQL JOIN. In general there is good SQL documentation available at the website of the RDBMS manfacturer. Go check it out. There is also a nice SQL tutorial at w3schools.com. Good luck.

  • Dynamic List of record subsets with a Many-to-many relationship

    I'm feeling pretty lost here and would appreciate any pointers.
    I'm trying to use ADDT to create a dynamic list of records that includes a subset of comma separated list of many-to-many related records. Specifically I'm listing a bunch of workshops that have various teachers associated with each workshops. Teachers team teach a variety of workshops, thus the need for a many-to-many link table.
    I've created a basic query to retrieve the workshop list, then another query to return the teacher's associated with the workshops. However I can't figure out how to use ADDT to list the teachers for each workshop.
    I have a sense that it has something to do with a nested repeat region but there does not seem to be a way to get the wizard to see beyond the link table.
    Am I way off here?
    Thanks!

    Hi,
    a list used in the singleSelectOne component does not change or set the currency in the list VO (in opposite to the navigation list). So this synchronization needs to be done programmatically. Examples of dependent list of values are available here
    --> example 62 http://radio.weblogs.com/0118231/stories/2004/09/23/notYetDocumentedAdfSampleApplications.html
    --> word document you can download from http://thepeninsulasedge.com/frank_nimphius/2008/05/16/blogbuster-treasures-hunt-blog-entries-from-the-lost-orablogs-blog-for-download/
    Frank

  • Adding a many-to-many relationship with AMO

    Does anyone have an example of adding a many-to-many relationship using AMO that is NOT the AMOAdventureWorks example?
    Specifically, I'm trying to do the following:
    1. Create the new measure group (cube.MeasureGroups.Add("New MeasureGroup"). This will be the factless measure group that's used to resolve the many-to-many
    2. Add a measure to it (something simple, like a Count)
    3. Add a regular cube dimension to the measure group linking one side of the many-to-many to a normal dimension
    4. Add a regular cube dimension to the measure group linking the other side of the many-to-many to a normal dimension
    (3. and 4. above are "RegularMeasureGroupDimension" type)
    5. Add a ManyToManyGroupDimension to the measure group. I use the ID of (3) above for its CubeDimensionID
    This is where I get stuck. I get an error "Another 'MeasureGroupDimension' object has the 'Requesting BU Lookup' key." (and this is the name of the dimension that I added in step 3).
    I could've sworn this worked just the other day! I can easily create these relationships using the GUI, but I just can't seem to get the AMO right to make it happen in code. Has anyone else been successful at this? I've stared a hole into AMOAdventureWorks, and it doesn't help :-(
    (BTW: Scripting to XMLA is not an option, because of the restricted environment where cube customization needs to take place)

    Dear John Lynn,
    Would you be willing to share the sample of your code? I'm having some troubles myself and would find another sample than the AMOAdventureWorks
    very helpful.
    Thanks in advance.

  • Many-to-One relationship with composed key

    Hi all,
    I have problems inserting an entity with a 1:n-relationship.
    The relationship is defined over two columns. In detail:
    There are two database-tables:
    VERDECK
    ID_PROJECT  NUMBER (key)
    ID_INTERN   VARCHAR2(10 BYTE) (key)
    UZSB
    ID_PROJECT          NUMBER (key)
    ID_UZSB             VARCHAR2(10 BYTE) (key)
    ID_PROJECT_VERDECK  NUMBER
    ID_INTERN_VERDECK   VARCHAR2(10 BYTE)
    On UZSB there is a referential integrity defined between these tables:
    FOREIGN KEY (ID_PROJECT_VERDECK, ID_INTERN_VERDECK)
    REFERENCES R57SCHRAUB.VERDECK (ID_PROJECT,ID_INTERN))
    This is mapped into JPA as follows:
    @Entity
    public class Verdeck implements Serializable {
         @EmbeddedId
         private VerdeckPK pk;
         @OneToMany(cascade={CascadeType.ALL},mappedBy="verdeck")
         private Collection<Uzsb> uzsbCollection;
    @Embeddable
    public class VerdeckPK implements Serializable {
         @Column(name="ID_PROJECT")
         private BigDecimal idProject;
         @Column(name="ID_INTERN")
         private String idIntern;
    @Entity
    public class Uzsb implements Serializable {
         @EmbeddedId
         private UzsbPK pk;
         @ManyToOne
              @JoinColumns({@JoinColumn(name="ID_PROJECT_VERDECK", referencedColumnName="ID_PROJECT"),@JoinColumn(name="ID_INTERN_VERDECK", referencedColumnName="ID_INTERN")})
         private Verdeck verdeck;
    @Embeddable
    public class UzsbPK implements Serializable {
         @Column(name="ID_UZSB")
         private String idUzsb;
         @Column(name="ID_PROJECT")
         private BigDecimal idProject;
    I try inserting a new entity VERDECK with some associated UZSBs as follows:
    Verdeck einVerdeck = new Verdeck();
    VerdeckPK myKey = new VerdeckPK();
    myKey.setIdProject(idProject);
    myKey.setIdIntern(lsId);
    einVerdeck.setPk(myKey);
    Uzsb lsUzsb = new Uzsb();
    UzsbPK lsUzsbKey = new UzsbPK();
    lsUzsbKey.setIdProject(idProject);
    lsUzsbKey.setIdUzsb(lsId);
    lsUzsb.setPk(lsUzsbKey);
    lsUzsb.setVerdeck(einVerdeck);
    Vector<Uzsb> uzsbColl = new Vector<Uzsb>();
    uzsbColl.add(lsUzsb);
    einVerdeck.setUzsbCollection(uzsbColl);
    em.persist(einVerdeck);
    As result I get the error
    "ORA-02291: integrity constraint (R57SCHRAUB.SYS_C0022330) violated - parent key not found"
    Does anybody have an idea? I think the problem could be the embedded key in Verdeck.
    Perhaps I should take this into account in my JPA-definition of the relationship?
    But how can I do this?
    Regards,
    Christoph

    Hi Christoph,
    our JPA implementation does not sort sqlstatements in the right order to work with foreign keys. This feature will come with the next release. The problem here is that databases check the constraint for every statement executed instead of checking at commit time (when our state is ok again).
    As workaround you can set the settings for the foreign key constraints to deferred (pls. see oracle docu: alter table defferrable / alter session deffered) and the database will check at commit time. Second approach would be to delete the foreign key constraints.
    hth
    -Andreas

  • Many-to-many relationship with date dependency

    Hi.
    We have an application which manages membership of users in groups.
    It is typical many-to-many relationship (table users and groups and
    relational table usersgroups). So far so good.
    But we would like to introduce another condition into this relationship
    - date validity.
    For example - person should belong to group only from date1 to date2.
    I think that relational table should contain not only a couple of id's but also
    a two dates (from-to) and all those four together should form primary key.
    Then we should need a condition (where) for such relationsphip.
    But toplink many-to-many mapping doesn't have any features for this.
    Have you any idea how to implement our requirement in another way?
    Thanks.

    Hello,
    I am not sure how you plan on setting those dates for each object in the ManyToMany collection.
    The only way I can think of is to treat the usergroup table as its own entity, as a wrapper over groups (or users) in the many to many collection, allowing the application to set the date values directly. This usergroup entity would have a 1:1 to both user and group, while user and/or group would have 1:M to usergroup.
    Best Regards,
    Chris

  • Creating data in a many-to-many-relationship

    Hello,
    we really have problems in implementing a JClient dialog based on BC4J for creating data in a many to many relationship - especially with cascade delete on both sides.
    Simplified our tables look like:
    create table A_TABLE
    A_ID VARCHAR2(5) not null,
    A_NAME VARCHAR2(30) not null,
    constraint PK_A_TABLE primary key (A_ID),
    constraint UK_A_TABLE unique (A_NAME)
    create table B_TABLE
    B_ID VARCHAR2(5) not null,
    B_NAME VARCHAR2(30) not null,
    constraint PK_B_TABLE primary key (B_ID),
    constraint UK_B_TABLE unique (B_NAME)
    create table AB_TABLE
    A_ID VARCHAR2(5) not null,
    B_ID VARCHAR2(5) not null,
    constraint PK_AB_TABLE primary key (A_ID, B_ID),
    constraint FK_AB_A foreign key (A_ID) references A_TABLE (A_ID) on delete cascade,
    constraint FK_AB_B foreign key (B_ID) references B_TABLE (B_ID) on delete cascade
    Could JDev Team please provide a BC4J/JClient sample that performs the following task:
    The dialog should use A_TABLE as master and AB_TABLE as detail. The detail displays the names associated with the IDs. Next to AB_TABLE should be a view of B_TABLE which only displays rows that are currently not in AB_TABLE. Two buttons are used for adding and removing rows in AB_TABLE. After adding or removing rows in the intersection the B_TABLE view should be updated. The whole thing should work in the middle and client tier. This means no database round trips after each add/remove, no posts for AB_TABLE and no query reexecution for B_TABLE until commit/rollback.
    This is a very common szenario: For an item group (A_TABLE) one can select and deselect items (AB_TABLE) from a list of available items (B_TABLE). Most of JDeveloper4s wizards use this. They can handle multi/single selections, selections from complex structures like trees and so on. Ok, the wizards are not based on BC4J - or? How can we do it with BC4J?
    Our main problems are:
    1. Updating the view of B_TABLE after add/remove reflecting the current selection
    2. A good strategy for displaying the names instead of the IDs (subqueries or joining the three tables)
    3. A JBO-27101 DeadEntityAccessException when removing an existing row from AB_TABLE and adding it again
    Other problems:
    4. We get a JBO-25030 InvalidOwnerException when creating a row in AB_TABLE. This is caused by the composition. We workaround this using createAndInitRow(AttributeList) on the view object (instead of create()). This is our add-Action:
    ViewObject abVO = panelBinding.getApplicationModule().findViewObject("ABView");
    ViewObject bVO = panelBinding.getApplicationModule().findViewObject("BView");
    Row bRow = bVO.getCurrentRow();
    NameValuePairs attribList = new NameValuePairs(
    new String[]{"BId"}, new Object[]{bRow.getAttribute("BId")});
    Row newRow = abVO.createAndInitRow(attribList);
    abVO.insertRow(newRow);
    5. After inserting the new row the NavigationBar has enabled commit/rollback buttons and AB_TABLE displays the row. But performing a commit does nothing. With the following statement after insertRow(newRow) the new row is created in the database:
    newRow.setAttribute("BId", bRow.getAttribute("BId"));
    Please give us some help on this subject.
    Best regards
    Michael Thal

    <Another attempt to post a reply. >
    Could JDev Team please provide a BC4J/JClient sample
    that performs the following task:
    The dialog should use A_TABLE as master and AB_TABLE
    as detail. The detail displays the names associated
    with the IDs. Next to AB_TABLE should be a view of
    B_TABLE which only displays rows that are currently
    not in AB_TABLE. Two buttons are used for adding and
    removing rows in AB_TABLE. After adding or removing
    rows in the intersection the B_TABLE view should be
    updated. The whole thing should work in the middle
    and client tier. This means no database round trips
    after each add/remove, no posts for AB_TABLE and no
    query reexecution for B_TABLE until commit/rollback.
    This is a very common szenario: For an item group
    (A_TABLE) one can select and deselect items
    (AB_TABLE) from a list of available items (B_TABLE).
    Most of JDeveloper4s wizards use this. They can
    handle multi/single selections, selections from
    complex structures like trees and so on. Ok, the
    wizards are not based on BC4J - or? How can we do it
    with BC4J?
    Our main problems are:
    1. Updating the view of B_TABLE after add/remove
    reflecting the current selectionYou should be able to use insertRow() to insert the row into proper collection.
    However to remove a row only from the collection, you need to add a method on the VO subclasses (and perhaps export this method so that the client side should see it) to unlink a row from a collection (but not remove the associated entities from the cache).
    This new method should use ViewRowSetImpl.removeRowAt() method to remove the row entry at the given index from it's collection. Note that this is an absolute index and not a range index in the collection.
    2. A good strategy for displaying the names instead
    of the IDs (subqueries or joining the three tables)You should join the three tables by using reference (and perhaps readonly) entities.
    3. A JBO-27101 DeadEntityAccessException when
    removing an existing row from AB_TABLE and adding it
    againThis is happening due to remove() method on the Row which is marking the row as removed. Attempts to add this row into another collection will throw a DeadEntityAccessException.
    You may 'remove the row from it's collection, then call 'Row.refresh' on it to revert the entity back to undeleted state.
    >
    Other problems:
    4. We get a JBO-25030 InvalidOwnerException when
    creating a row in AB_TABLE. This is caused by the
    composition. We workaround this using
    createAndInitRow(AttributeList) on the view object
    (instead of create()). This is our add-Action:
    ViewObject abVO =
    O =
    panelBinding.getApplicationModule().findViewObject("AB
    iew");
    ViewObject bVO =
    O =
    panelBinding.getApplicationModule().findViewObject("BV
    ew");
    Row bRow = bVO.getCurrentRow();
    NameValuePairs attribList = new NameValuePairs(
    new String[]{"BId"}, new
    String[]{"BId"}, new
    Object[]{bRow.getAttribute("BId")});
    Row newRow = abVO.createAndInitRow(attribList);
    abVO.insertRow(newRow);This is a handy approach. Note that Bc4j framework does not support dual composition where the same detail can be owned by two or more masters. In those cases, you also need to implement post ordering to post the masters before the detail (and reverse ordering for deletes).
    >
    5. After inserting the new row the NavigationBar has
    enabled commit/rollback buttons and AB_TABLE displays
    the row. But performing a commit does nothing. With
    the following statement after insertRow(newRow) the
    new row is created in the database:
    newRow.setAttribute("BId",
    d", bRow.getAttribute("BId"));This bug in JDev 903 was fixed and a patch set (9.0.3.1) is (I believe) available now via MetaLink.
    >
    >
    Please give us some help on this subject.
    Best regards
    Michael Thal

Maybe you are looking for

  • TOC with Multiple TR's is taking more than 24 hours of time to release ?

    Hi All, TOC with Multiple TR's  When Released  is taking huge amount of time to release ,  more than 24hours, what needs to be  done ,  when checked the Log of the particular   TR in SE01 Getting  the following Export phase="Export        21.02.2010

  • Will I need to pay more money to send a song I purchased to a friend?

    If I buy a song on itunes how can I send it to a friend?  Will it charge me more to send it if I already purchased the song myself?

  • Frozen 4G iPod, continual Apple Symbol

    Hi, My iPod stopped working yesterday randomly. I ejected it from my computer as normal, it finished ejecting and I unplugged it. Then it started this continual resetting mode that it is in now. The apple symbol is there, it dissapears for a half a s

  • Restart Hang

    Hi forum, My PC keeps hanging when I attempt to restart.  It just hangs in the restart screen until eventually a power down is the only option (via power button). After reading a few bits on the web and due to frustration I opted for a fresh install.

  • Confusion about scanning over network

    I have tried to find the answer but keep coming up with conflicting posts. I have a Canon MP530 all-in-one connected to my Airport Extreme (flying saucer model). I can see and print from both my Windows 7 laptop and also my MBP. I understand the Airp