Portal Form for a Many to Many relationship

I have 3 tables (well there are actually more but i'm glad when i can do the trick with 3 at the moment):
T_JOURNAL (JOURNAL_ID, JOURNAL_NAME)
T_CONTENTBROKER (CONTENTBROKER_ID, CONTENTBROKER_NAME)
HT_JOURNAL_CONTENTBROKER (JOURNAL_ID, CONTENTBROKER_ID)
The HT stants for 'help table'. T_JOURNAL and T_CONTENTBROKER have a many to many relationship. So one Journal can have many Broker and one Broker has many Journals.
When doing a Form in Oracle Portal for adding a new Journal, i'd like to have a LoV with the Brokers. But an new entry would at least require 3 tables to update (T_JOURNAL, T_CONTENTBROKER and the help table HT_JOURNAL_CONTENTBROKER). How can this be solved? i'm not very good with pl/sql... so if there is only a solution with pl/sql i would be glad for the code...
I also tried to create a view wich would show me the journal with all its broker but i kind of failed...
any suggestions appreciated ;)
- renato

Thanks for the info. I tried that and it still doesn't pull the value. I have opened a TAR via metalink, but I'm not getting any
satisfactory answers. I ran across an note - 137172.1 that has this snippet of information in it.
Unfortunately, at this time (portal 3.0.7.6.2) , a non-table item cannot be
referenced in a plsql event handler, only in client side JavaScript code. This
is a known limitation and will be fixed in a future release.
I don't know how to get the value from the client side JavaScript code to a pl/sql variable. Do you?
I've been trying to get them to tell me if the 'known issue' has been addressed in 3.0.9.
I'll keep at it. Thanks so much for your suggestion I appreciate it.
Deb

Similar Messages

  • How do I get a value from a portal form for a non database field ? HELP!!

    I have a form based off of a table that I added a field to. The form is to allow the user to change abbreviation for a
    department field ie. BIO to BIOL. for a biology department. I have a pl/sql procedure for validation using the custom option
    on the update button to verify the user and update the data. I have tested to code at the sql prompt and it works.
    They only difference between the prompt and the form is the non-database field new_dept_abbr was added to the
    form. I don't know how to capture the value of the user input into a variable that can be used in the pl/sql.
    Any help would be appreciated.
    I have tried this approach
    v_new_dept_abbr := p_session.get_value_as_varchar2(
    p_block_name => 'default',
    p_attribute_name => 'new_dept_abbr'
    have tried using p_attribute_name as 'a_new_dept_abbr' but this does work and does not exist in the body of the form.
    Have also tried setting the p_block_name to _session - still doesn't work.
    Any ideas??
    Thanks
    Debbie Brennan

    Thanks for the info. I tried that and it still doesn't pull the value. I have opened a TAR via metalink, but I'm not getting any
    satisfactory answers. I ran across an note - 137172.1 that has this snippet of information in it.
    Unfortunately, at this time (portal 3.0.7.6.2) , a non-table item cannot be
    referenced in a plsql event handler, only in client side JavaScript code. This
    is a known limitation and will be fixed in a future release.
    I don't know how to get the value from the client side JavaScript code to a pl/sql variable. Do you?
    I've been trying to get them to tell me if the 'known issue' has been addressed in 3.0.9.
    I'll keep at it. Thanks so much for your suggestion I appreciate it.
    Deb

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

  • Seek good method for deleting many to many relationship

    My question is as follows:
    The relationship of Employee and Project is many to many. I set privately owned for employee-project relationship at toplink builder.
    Employee class has a vector of valueholder attribute of Project list.
    I write a function to remove a project relationship from Employee when his is no longer responsible for it.
    public void removeProjectFromEmployee(String employeeId, String projectId)
    throws Exception
    DataSource src = this.getSource();
    Employee emp = getEmployeeById(employeeId);
    if (emp == null) {
    throw new Exception("employee with id " + employeeId + " does not exist.");
    else {
    Vector projectVector = emp.getProjects();
    for (int i=0; i<projectVector.size(); i++){
    Project p=(Project)projectVector.elementAt(i);
    if ((p.getProjId()).equals(projectId)) {
    projectVector.removeElementAt(i);
    emp.setProjects(projectVector);
    src.registerObject(emp);
    src.commit();
    In here, i select the object of the employee and then remove one particular project from the vector. It is working but seemed to be quite stupid. Moreover, i worry about its performance when there are thousands of projects owned by an employee.
    I think it is a very common operation but i am not very familiar with TOPLink at this moment. Could anyone please advise the correct and better way to deal with this situation?
    Thanks

    Hello,
    Try registering your employee in the UnitOfWork before you re-set the collection onto it. This should resolve your problem.
    Note: When you set the collection on the unregistered Employee object, you were modifying a shared, read-only instance of the object, and hence were making transactional changes visible to other threads non-atomically. There are a lot of good reasons why this is a bad thing.
    I hope this helps,
    Christian

  • WCF RIA entity Update from Lightswitch for Many to many relationship

    I have two entities which have many to many relationship. I need to create a screen to update data from both the tables simultaneously using a screen. So I used First as a sql database entity in Lightswitch second is RIA service Entity(Which is junction table).
    both tables are editable in a same screen but when I click on Save button,
    System call to
    [Query(IsDefault = true)]public IEnumerable<EquipmentJob> SelectFakeJobs()  
    method instead of calling
    [Query]public IEnumerable<EquipmentJob> SelectJobs(long? ID).
    I am using the Ria table as a query in my screen and setting the parameter as a table1.SelectedItem.ID.  But after click on save it does not call to parameterized
    method to get data. I have already implemented the 'Saving' method.  It gives following exception.
    Only changes to a single data service can be saved.  To save changes to multiple data services, implement the "Saving" method.
    Data conflict. another user has deleted the record.
    I followed following link to setup the Many to Many relationship update in LightSwitch
    http://powerbala.com/many-to-many-control-for-microsoft-lightswitch/

    Only changes to a single data service can be saved.  To save changes to multiple data services, implement the "Saving" method.
     This issue is discussed before, generally you need implement the <ScreenName>_InitializeDataWorkspace method and add the data services that you'd like to save to the saveChangesTo list.
    https://social.msdn.microsoft.com/Forums/en-US/238e5e91-8598-42f9-817d-12b6f5b980a1/having-a-problem-saving-getting-error?forum=lightswitch

  • Need example of adding attributes for many-to-many relationship

    Hi,
    Looking for examples of mappings and update code for many-to-many relationships with attributes.
    There is a doc in Metalink:206971.1 that says that it can be done but no examples are shown.
    Would realllly appreciate any help you can provide.
    Cheers,
    Nim

    Extended Many to Many Question
    Really there isn't any code to show. The recommendation is to create a class to represent the relationship. See link above for more details on the issue.
    - Don

  • Many to many relationship for recursive table

    HI friends,
    I have a use-case where I have several tasks that are inter-dependent on each other. Like one task will execute only if other tasks (which can be more than one) are successful. I am not able to decide what the database design should be for this. If there should be a relationship table with a self-join something like this-
    CREATE TABLE Item (
    ItemId int,
    status varchar,
    PRIMARY KEY(ItemId));
    CREATE TABLE Item_Relation (
    itemId int,
    dependsOnItem int,
    PRIMARY KEY(itemId, dependsOnItem),
    FOREIGN KEY(itemId) REFERENCES Item (ItemId),
    FOREIGN KEY(dependsOnItem) REFERENCES Item (ItemId));
    is it recommmended because this is the only solution I see for this?
    Thanks.

    Looks like your trying to embedd business logic in the database tables. It should be in your java project only.
    I suggest you keep your database simple with basic associations between tables (foreign keys). The database
    is for storing data that many applications aside from yours will want to use. Your specific business logic requirements
    should not be in it.
    In your java code, you can use transactions in your sql to rollback if something isn't the way it should be.
    However, I would not suggest you put your task verification problem code handling in the rollback block of code.
    Instead, I suggest you query the database tables and determine if the previous tasks are ok to do the current unit of work.
    If so, perform the unit of work (say, write to some other database table). If not, return a message on what the problem is
    (better yet, have a validation function that verifies the pervious tasks have been done). All of that should be in a transaction
    to play it safe. Why you ask?
    The problem is, even if your validation function says the previous tasks are complete, by the time you perform the new unit
    of work, the database may have changed and the validation is not longer valid. Therefore you rollback may still occur (ensures the
    data in the database is not in an invalid state) Normally in that case, you rollback and tell the user to repeat the operation
    (see optomistic concurrency). Exactly how you plan on handling these side issues is up to you.

  • How to create a many to many relationship in forms 10g

    hello frnds,
    I want to create many to many relationship, can any one help me plz?
    Regards
    Divya Alok

    Hi ,
    In this situation create two separate blocks one is master and the other one is detail block.
    Then make detail block as database data block with the proper table name.Pass the value that your enter in the master block to the detail block as the search criteria to fetch the data from the table and to show the data related to the master value .If you have multiple master values then create data base data block sql query in such way that it must use all the master inputs as the search criteria.
    EX. Some time user wants to see the details of the employee after entering the emp id as the search criteria,that time you have to pass emp id as the search criteria to detail data base data block.Even you can pass emp id and emp name as the search criteria to the detail database data block.
    Thanks,
    Pavan.

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

  • [ADF] Adding/deleting entries in a many-to-many relationship

    I am using JDeveloper 10.1.3 and the ADF BC / ADF Model / ADF Faces / JSF technology stack.
    For this question, I am using the SRDemo application as an example, specifically the many-to-many relationship between USERS and PRODUCTS (the Staff Expertise relationship), outlined in red in this schema diagram: Image Link
    Users may have any number of product expertise areas and many users may have the same product expertise area. For the purposes of this example I have added two reference fields from the PRODUCT table into the ExpertiseAreas VO (Name and Description), outlined in red in this data control palette section: Image Link
    I have created a page which shows the details of a user (1), along with a table showing the expertise areas the user has (3), and a table of all the products available (2), numbered on this design page: Image Link and corresponding to the numbered data controls on this data control palette section: Image Link, where 1 is rendered as an ADF Read-only Form, 2 is an ADF Read-only Table with a tableSelectMany element in the selection facet, and 3 is also an ADF Read-only Table.
    What I am trying to do is have the tableSelectMany element reflect which of the products are linked to the current user in the expertise areas relationship (by having the checkbox for currently linked products checked), and when you check or uncheck a product's checkbox, it should add or remove the row in the EXPERTISE_AREAS intersection table, respectively (asume for this example that there are default values for Expertise Level and Notes).
    So far I have been following the process used in section 19.8 of the ADF Developer's Guide for Forms/4GL Developers, which describes how to set up a selectManyShuttle which implements the adding and deleting functionality. So I have a Client Interface method in the Application Module, updateSkillsForCurrentStaff (described in section 10.6.7.2), and I have a selection listener for the assignment table in the backing bean for the page, which calls the updateSkillsForCurrentStaff method:
    public void selectionChanged(SelectionEvent event)
      BindingContainer bc = getBindings();
      DCIteratorBinding productsIB = (DCIteratorBinding)bc.get("ProductListIterator");
      Set keys = getTable1().getSelectionState().getKeySet();
      Iterator iter = keys.iterator();
      List productIds = new Vector();
      while (iter.hasNext())
        String product = ((Key)iter.next()).toStringFormat(true);
        productsIB.setCurrentRowWithKey(product);
        ViewRowImpl productRow = (ViewRowImpl)productsIB.getCurrentRow();
        Number productId = (Number)productRow.getAttribute("Id");
        productIds.add(productId);
      OperationBinding ob = bc.getOperationBinding("updateSkillsForCurrentStaff");
      Map pm = ob.getParamsMap();
      pm.put("productIds", productIds);
      ob.execute();
    All of this works, but I can't work out how to link the selection state of the assignment table to the expertise areas that are linked to the user. Also I think the method listing above must be a bit of a hack, but I don't know enough about this to know if there's an easier way of doing it.
    Any help is appreciated.

    Have a look at this example I cooked up for you.
    http://radio.weblogs.com/0118231/2006/10/03.html#a739
    It might not be the first way one thinks to implement something, but it illustrates a very interesting, model-centric approach to the problem you propose.
    My feelings won't be hurt if you prefer a more view-centric approach, but I wanted to illustrate what was a maximally-model-centric solution (in fact, which doesn't even require a backing bean!) If you like a more view-centric approach, I can help you figure out what's wrong with your key-handling above. For one, I would probably start by passing the Set of Key's directly to the middle tier application module method to eliminate client-side code.
    Check it out and let me know what you think. Try it directly in the Business Components Tester to appreciate one of the benefits a model-centric solution can bring.

  • 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

  • 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

  • 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

  • Many to Many relationship in JSP

    I have 3 tables in mySQL database.
    Table 1: Customer_Particular
    Fields: custID(PK), name, age
    Table 2: CusHob
    Fields: custID(PK), hobbiesID(PK)
    Table 3: Hobby
    Fields: hobbiesID(PK), hobbies
    Relationship: Many to Many
    Meaning: One customer can have many hobbies, and one hobby can have many customer.
    I have a form, i.e. customer.jsp, which has name, age, hobbies. User can select more than one hobbies(I have constructed using checkbox). User can add/delete the hobbies by click the Edit link. After update the hobby list, the checkbox will be shown according to the latest info in the database.
    How to implement this ? I feel that it is difficult because name and age will be added to the database, while hobbies will be added to CusHob table.
    If can, what about during Edit time?
    Jeff

    I analyse your problem as follows:-
    1. You want to maintain database of users with the name, age and hobbies listed in the database.
    2. User registers himself/herself. He/She has to fill in the information like
    * name
    * age
    * select hobbies from the list by checking the checkbox against each hobby which he/she wants to select.
    The user may have a hobby which is not present in the list, so he has the option to add the hobby and select it.
    What should be the logic?
    Firstly the user will be shown the jsp page Customer.jsp, which has 2 text boxes one for name and other for age. Nothing is dynamic in these two. The dynamically generated option would be hobbies. These hobbies would be taken from the database table Hobby by the SQL query
    select * from Hobby;
    You scroll through the result set and display all the field names, the value of the checkbox would be the HobbiesID and the name displayed would be hobbies.
    If the user finds his hobbies with in the list, he selects the hobbies after filling in the name and age and submits the form. The form is submitted to a servlet which processes the request.
    Request processing by servlet
    The request processing servlet takes the request parameters and starts a transaction. It is important to start a transaction here, by invoking the following method on Connection object.
    con.setAutoCommit(false); because by default every database update or insert is committed after execution of SQL statement using JDBC.
    Now the transaction has 2 parts:-
    Start Transaction
    a. insert the name and age in Customer_Particular table, this will generate the Cust_Id.
    b. get the Cust_Id from the Cutomer_Particular table.
    c. Insert the Cust_Id and all the HobbiesID against that CustID into CusHob table.
    Commit Transaction
    The above scenario is for the case when the user selects the hobbies from the listed hobbies, but there is one other scenario when the user can add hobby. For this the user clicks on Add Hobby option after filling the name of the hobby in the text field adjacent to AddHobby button. When the user clicks Add Hobby it invokes a servlet "AddHobby.class" ,which inserts a hobby in the Hobby table and forwards the request to "Customer.jsp" page which again retreives the hobbies dynamically and now the new hobby added by the user is also one of the options.
    The user fills in the form and presses the submit button.
    Hope this helps

  • AWM - many to many relationship in a levels hierarchy

    Hi, I'm using awm 11.2 and the problem is, how to create relationship in this case:
    I have a customer dimension with a hierarchy that has the following levels:
    1. gender
    2. date_of_birth
    3. country
    4. city
    5. street_address
    6. first_last_name
    Problem is the relationship between gender and date of birth, because they can have gender the same number of dates of birth and vice versa.
    Is it possible to do this in the AWM and how?
    Thanks

    Oracle OLAP hierarchies are many to one only (that is, many children to a single parent). Depending on the query tool you are using, consider modeling many to many items as attributes and creating the hierarchy in the query tool (many to many hierarchies are supported in almost every relational BI tool). For example, if you are using a tool such as Oracle Business Intelligence, you might model your OLAP hierarchy as Name > Address > City > Country with Gender and Date of Birth as attributes of Name. In most relational query tools, you can make a hierarchy of any of the columns.
    This will probably work well from a modeling perspective, but you will have some exposure to performance challenges because any query on Gender and Date of Birth will require all of the customer records that are related to them. For example, if you query for all records by Gender, the query will need all customers. In an extreme case, lets say you have a billion records by customer. If you ask for a break out by gender, without any other filters, the query will need all billion records form the cube. That's not going to be good. On the other hand, if the query has some filters (e.g., customers in Boston that purchased Shoes in December 2011) the number of records that need to be returned by the cube is drastically reduced, which might be perfectly fine.

Maybe you are looking for