EJB and many-to-many relationship

I write two CMP Beans userBean and roleBean with many-to-many relationship
userBean:
  cmp fields: id,name
  cmr fields: userRoles
roleBean:
   cmp fields: id,rolename
   cmr fields: usersinroleIn database I have 3 tables:
USER( ID NUMBER PK,NAME CHAR);
  ROLE( ID NUMBER PK,ROLENAME char);
  USER_ROLE( (USERID FK(USER.ID), ROLEID FK(ROLE.ID)) PK);in sun-cmp-mappings.xml I add cmp fields mapping,
in userBean and roleBean I add secondary table USER_ROLE
then I add CMR mappings to userBEan nd roleBean
ufter deploying of EJB.jar
in client i wrote:
userBeanLocalHome lh=lookupUser();
lh.create(new java.math.BigDecimal(5),'username');when i run client exception occurs in server log I see:
TransactionRollbackException because Container try to insert into USER_ROLE
values(5(userid),null(roleid)) but user have no roles
in that situation how can I create user without any roles?
thanx!

FaraPooyan, I think about this but it is not good idea because it makes 1-n:1-m relationship.
but I whant 0-n:0-m relationship
I resolve this problem by removing secondary table from sun-cmp-entitymappings.xml
So it works good, but now i dont understand: when i need secondary table mapping if they are not needed for many-to-many relationships

Similar Messages

  • Many to Many Relationships in ejb.....Urgent Pls help

    hi all,
    Am working in EJB.Now we are coding for many to many relationship.
    Company and Salary register
    One Company can have many salary register and More than one company can have one salary register
    Companyand Salary register are the two tables having details of it.And the intermediate table having pk of company and salary register is Company_salary_register table,I want to add the value in this table having seperate interface.
    How to model it? I have given the add method of this company_salary_register table in company bean.I am getting the value of this one as collection.But it is asking me to add the values as the instance of LocalSalary(interfaceand entitybean).If i type cast it as Local Salary Class castexception occurs
    Please help me.Even Material of Modelling Many to Many relationship in EJB is enough.
    thanx in advance,

    THaaaaaanks alottt for the quick reply...
    I used the first way to insert the document and i was successful...
    but thing is that..
    when i do
    SQL>desc message_type
    message_type is NOT FINAL
    Name Null? Type
    SYS_XDBPD$ XDB.XDB$RAW_LIST_T
    to VARCHAR2(4000 CHAR)
    from VARCHAR2(4000 CHAR)
    subject VARCHAR2(4000 CHAR)
    body VARCHAR2(4000 CHAR)
    i can see the structure...
    and when i
    select count(*) from messages
    it says count is 1.
    so how to know where the data is ..like below in the data :
    'to' it has '[email protected]'
    and for 'from' it has '[email protected]'..and so on..
    <message>
    <to>[email protected]</to>
    <from>[email protected]</from>
    <subject>Question</subject>
    <body>Does this demo work?</body>
    </message>
    so what is the command to get that data...
    because when i do
    select * from message_type..it says
    select * from message_type
    ERROR at line 1:
    ORA-04044: procedure, function, package, or type is not allowed here
    Plss help me outt.......this will be my final step...
    Thankssssssssssssssss

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

  • Help: IllegalExpressionException vs. EJB 2.1 many-to-many relationship

    Using Oracle WebLogic 11g (10.3.4). The appc tool is generating a warning regarding an illegal EJB QL expression for a many-to-may relationship in an EJB 2 Bean.
    Details:
    * Entity Bean "MSProduktKonfiguration"
    * Entity Bean "MSAngebot"
    * n-m relationship betwenn these two Entites, from MSProduktKonfiguration to MSAngebot by cmr field angebotLocal, from MSAngebot to MSProduktKonfiguration by cmr field produktKonfigurationenLocal
    * Join table "MS_PRODUKT.ANGEBOT_POSITION"
    Warnings from appc:
    [java] Warning: [EJB:013094]The SELECT clause of this query contains an identifier 'bean.angebotLocal' that ends in a cmr-field. The EJB 2.1 specification section 11.2.7.1 requires that any related null objects belonging to the set corresponding to this cmr-field must be returned by this query however the database that will be used to execute this query does not sufficiently support SQL outer joins, therefore this query will not return any null objects that might otherwise be returned.
    [java] Warning: [EJB:013094]The SELECT clause of this query contains an identifier 'bean.produktKonfigurationenLocal' that ends in a cmr-field. The EJB 2.1 specification section 11.2.7.1 requires that any related null objects belonging to the set corresponding to this cmr-field must be returned by this query however the database that will be used to execute this query does not sufficiently support SQL outer joins, therefore this query will not return any null objects that might otherwise be returned.
    I have no clue what's going on there. Maybe someone can help me out.
    Snippet from the ejb-jar.xml Deployment Descriptor:
    <ejb-relation id="EJBRelation_9">
    <ejb-relation-name>Angebot-ProduktKonfiguration</ejb-relation-name>
    <ejb-relationship-role id="EJBRelationshipRole_17">
    <ejb-relationship-role-name>ProduktKonfigurationen-Have-Angebote</ejb-relationship-role-name>
    <multiplicity>Many</multiplicity>
    <relationship-role-source id="RoleSource_17">
    <ejb-name>MSProduktKonfiguration</ejb-name>
    </relationship-role-source>
    <cmr-field id="CMRField_9">
    <cmr-field-name>angebotLocal</cmr-field-name>
    <cmr-field-type>java.util.Collection</cmr-field-type>
    </cmr-field>
    </ejb-relationship-role>
    <ejb-relationship-role id="EJBRelationshipRole_18">
    <ejb-relationship-role-name>Angebote-Have-ProduktKonfigurationen</ejb-relationship-role-name>
    <multiplicity>Many</multiplicity>
    <relationship-role-source id="RoleSource_18">
    <ejb-name>MSAngebot</ejb-name>
    </relationship-role-source>
    <cmr-field id="CMRField_10">
    <cmr-field-name>produktKonfigurationenLocal</cmr-field-name>
    <cmr-field-type>java.util.Collection</cmr-field-type>
    </cmr-field>
    </ejb-relationship-role>
    </ejb-relation>
    Snippet from the weblogic-cmp-rdbms-jar.xml Deployment Descriptor:
    <weblogic-rdbms-relation>
    <relation-name>Angebot-ProduktKonfiguration</relation-name>
    <table-name>MS_PRODUKT.ANGEBOT_POSITION</table-name>
    <weblogic-relationship-role>
    <relationship-role-name>Angebote-Have-ProduktKonfigurationen</relationship-role-name>
    <relationship-role-map>
    <column-map>
    <foreign-key-column>angebot_id</foreign-key-column>
    <key-column>angebot_id</key-column>
    </column-map>
    </relationship-role-map>
    </weblogic-relationship-role>
    <weblogic-relationship-role>
    <relationship-role-name>ProduktKonfigurationen-Have-Angebote</relationship-role-name>
    <relationship-role-map>
    <column-map>
    <foreign-key-column>produkt_konfiguration_id</foreign-key-column>
    <key-column>produkt_konfiguration_id</key-column>
    </column-map>
    </relationship-role-map>
    </weblogic-relationship-role>
    </weblogic-rdbms-relation>

    Hi,
    There are many differences between EJB 1.1 and 2.0. Most of these are
    regarding CMP entity EJBs. I would say you should go with 2.0 if you have
    entity EJBs.
    Also EJB 2.0 has local interfaces and message-driven beans (JMS listeners).
    Emmanuel
    "Brian" <[email protected]> wrote in message
    news:3cf3b4eb$[email protected]..
    >
    Our standard development tool here is WebGain Visual Cafe 4.5.1. I am toldthat this
    tool does not support EJB 2.0. We are generating EJB's through the wizardbased interface
    of Visual Cafe.
    Is there a compelling reason to use EJB 2.0 instead of 1.1, even thoughthe tool
    doesn't support it? Is the time saved by automatic generation of EJB 1.1beans outweighed
    by improvements in EJB 2.0?
    Thanks for you help!

  • How to design many to many relationship in the fact and dimension

    There is a problem in my project what is the subject.And i wanna know how to implement in owb.I use the warehouse builder 10. Thanks.

    You may design and load whatever db model you want to.
    But If you set a unique key, you may find some integrity issues. I wouldn't do a many to many relationship between facts and dimensions. This could cause you lots of headaches when users start to submit queries using this tables. You'll probably face performance issues.
    Regards,
    Marcos

  • Many to Many relationship betwee dimension and fact tanle

    Hello Gurus,
    I have a little question about many to many realtionship between fact and dimension table. The situation is as follows.
    Consider there is a fact table F1 and two dimension tables D1 and D2. D1 is joined to F1 with 1 to many relationship. D1 is joined to D2 with again one to many relationship ( Note: D1:D2 = 1:N and D1:F1 = 1:N). I am able to model this by merging D1 and D2 into one dimension table in BMM layer by adding them as logical table sources and creating logical table source join. I have built simple reports and the data returnned is fine. However, I would just like to know what could be the drawbacks of such a model.
    We have many other dimesions joined to the fact table and users have access to the answers that means they would could what ever report they feel like. Hence, would just like to know in what cases this model could break which means reports would give wrong data because of a many to many relationship between one of the fact and dimension table.
    Thanks in advance.

    Hello Copter,
    Even I had modeled it by reading this link before. In the situation explained by me dimension D1 is doing the job of table Rules ( as explained in link). The model is fine.
    However, my point is to undersatnd in which scenerios this model will break. As already explained, the fact table is joined to various other dimensions, there could be situations in which users select columns from various dimensions and facts randomly.
    Hence, which are the scenerios where I might get erroneous counts of meassures. Further, if someone feels this model is correct and would not break in any scenerio then please reply.

  • Many to many relationships between Fact and Dimension

    Hi All,
    I have to solve two kind of many to many relationships between Fact and Dimension.
    1. Many to Many relationship between Fact and Dimension, using a bridge table, with FKs in fact and dimension to bridge table’s PK.
    2. Many to Many relationship between Fact and Dimension, using a bridge table, and an intersection table, with FK in fact to bridge table, and 2 FKs in intersection table to Dimension and to bridge table.
    I need help on implementing (how the mapping has to look like) them in OWB 9.2.0.2.8.
    Thanks,
    Aurelian Cojocaru

    Aurelian,
    Unfortunately, you cannot implement this in the dimensional model. You would have to use relational tables and relationships between those in order to implement your scenario.
    Thanks,
    Mark.

  • Many to many relationship EJB

    hi there,
    Do you know where to find an example of a project made with the developer studio using a many to many relation ship between EJB ?
    thanks,
    FM

    Frantz,
    unfortunately I don´t have a ready-to-use sample project. But this task is well documented at sap help. You need a helper table in your data dictionary to manage the relation.
    Check this link...
    SAP Help CMP
    Try to develop your own project and ask here if you have any issues.
    Regards
    Sebastian
    Message was edited by: Sebastian Voss

  • Two tables that have both "many-to-many" and "one-to-many" relationship

    i have the following two tables one represents the users and the other represents articles where each article can have one author(user) and of course the users can author many articles, so the relationship is one-to-many:-
    1. Users:-
    User_id (primary_key)
    User_name
    User_sex
    user_address
    2.Articiles:-
    Article_id
    Text
    Author_id (foreign key to the users.user_id)
    but the problem that i have faced is that on another requirement each articles can have multiple approval (users) before being published, so in this way the relation have became many-to-many, so i have created a third table named "approvals":-
    3.Approval:-
    approval_id (foreign key to the users.user_id)
    article_id (foreign key to the articles.article_id)
    level.
    so is this a good approach to flow , or there are another way that i can better build these tables.

    sb92075 wrote:
    approval_id (foreign key to the users.user_id) I am not clear on data element above.
    I thought USERS were really AUTHORS. yes the authors are users , and the author id is exactly the same as user id.
    and any user can be author if a flag in the users table is set to yes and he is involved in a workflow.
    so do authors approve their own articles? no
    do non-authors approve articles?
    What is "level" in APPROVAL table?
    What is PK for APPROVAL table? level indicates the workflow steps if there are multiple steps in the workflow ,for example the first approval is on level one, and the second approval is on level two,etc
    the primary key for the approval will be article_id and the user_id

  • Many to many relationship between category and category set?

    Is there a many to many relationship between category
    and category sets in Inventory mgmt?
    I mean, one category can exist in many category sets
    and one category set can have many categories, is that true?

    Is there a many to many relationship between category
    and category sets in Inventory mgmt?
    I mean, one category can exist in many category sets
    and one category set can have many categories, is that true?

  • How can I establish many to many unidirectional relationship?

    Hi, EJB Fans!
    I am an ejb fan too.
    This time I am learn ejb2.0 and find very funny in cmr. I think it is a good idea and can do manythings we cann't do or difficult with ejb1.1.
    But in many to many relationship, I don't know how to give my tables to entity A and entity B. How can I define tables to make A contains related Bs' information? And so do B. But i think make this table is difficult, because we don't know exactly how many should contains? And this is an examples:
    Difine entity A as User, and B as roles such as Administration, user, power user, as we often used in network. A user can have many roles, and roles can allocated to many roles.
    Another examples is entity A as person, and B as Department. B container A, and A can join many department as he or she can.
    B can find A(s) with which clues?? Methods like this java.util.Collection getAs()
    , this collection how can ejb container caculate it out?
    It is very myth, even wonderful!
    I love java and more like ejbs.

    No body reply.
    My question is silly or my english is very bad.
    Sorry I am chinese-speaking programmer.

  • Plea for example - Many-to-Many CMP EJB

    I am attempting to create an EJB that uses Container Managed Persistence,
    but my situation seems to be an odd one. The EJB needs to have a
    Many-to-Many relationship to itself, because the object is Hierarchical.
    Because this is my first EJB I am having a hard time with all of the
    deployment descriptors.
    I am asking for an example of any Many-to-Many EJB relationship that uses
    Weblogic's built-in link table creation to make the relationship (that
    works). I realize that there are confidentiality issues with many people
    releasing code. I will make any promise (short of selling my soul) that the
    code will be safe and promply destroyed immediately after inspection.
    Thanks for any help,
    Tom
    [email protected]

    The following describes how to establish a self many-to-many relationship with regards to Product having many parent products and many children products. I have attached the example files as well. Most of these files were generated using EJBGen. I would highly recommend it...
    EJB
    v Navigating from a Product to its parent Products results in getParents() method in Product
    § Since a Product can have many parents the return type of getParents() method is
    java.util.Collection
    § Calling setParents() method results in establishing the new links between this Parent and
    parent Products
    § Adding a Product as Parent to the Product results in establishing a new link between this
    Product and other Product as parent
    · This product is made available in the collection of children in the other Product
    § Removing a Product as Parent to the Product results in breaking a link between this
    Product and the other Product as parent
    · This product is also removed from the collection of children in the other Product
    v Navigating from a Product to its children Products results in getChildren() method in Product
    § Since a Product can have many children the return type of getChildren() method is
    java.util.Collection
    § Calling setChildren() method results in breaking the old links between this Product and
    children Products
    § Adding a Product as child to the Product results in establishing a new link between this
    Product and other Product as child
    · This product is made available in the collection of parents in the other Product
    § Removing a Product as child from the Product results in breaking a link between this
    Product and the other Product as child
    · This Product is also removed from the collection of parents in the other Product.
    v Example: ProductBean
    Ø DataBase
    v For a many-to-many relationship define a new associative (join) table
    v Define a new Parent_Child_Product associative table
    v The Parent_Child_Product has compound primary keys: Parent_Product_ID and
    Child_Product_ID
    v Parent_Product_ID and Child_Product_ID are foreign keys to Product table
    v Example: Product, Parent_Child_Product
    Ø Deployment Descriptors
    v ejb-jar.xml
    § Within <ejb-jar>.<relationships>.<ejb-relation> define the following:
    · Name of the relationship
    o Example: <ejb-relation-name>Parent-Product-Children</ejb-relation-name>
    · Role from the parent Product side
    o Source
    § Example:
    <relationship-role-source>
    <ejb-name>Product</ejb-name>
    </relationship-role-source>
    o Role name
    § Example: <ejb-relationship-role-name>many-Product@children-Have-Product</
    ejb-relationship-role-name>
    o Multiplicity
    § Example: <multiplicity>many</multiplicity>
    o CMR field
    § Example:
    <cmr-field>
    <cmr-field-name>children</cmr-field-name>
    <cmr-field-type>java.util.Collection</cmr-field-type>
    </cmr-field>
    · Role from the child Product side
    o Source
    § Example:
    <relationship-role-source>
    <ejb-name>Product</ejb-name>
    </relationship-role-source>
    o Role name
    § Example: <ejb-relationship-role-name>many-Product@parents-Have-Product</
    ejb-relationship-role-name>
    o Multiplicity
    § Example: <multiplicity>many</multiplicity>
    o CMR field
    § Example:
    <cmr-field>
    <cmr-field-name>parents</cmr-field-name>
    <cmr-field-type>java.util.Collection</cmr-field-type>
    </cmr-field>
    v weblogic-ejb-jar.xml
    v weblogic-cmp-rdbms-jar.xml
    § Within <weblogic-rdbms-jar>.<weblogic-rdbms-relation> specify the following:.23
    · Name of the relationship matching the name in ejb-jar
    o Example: <ejb-relation-name> Parent-Product-Children</ejb-relation-name>
    · Specify the name of the joint table
    o Example: <table-name> Parent_Child_Product</table-name>
    · Specify the mapping using <weblogic-relationship-role>
    o Specify the role name matching the name in the ejb-jar
    § Example: <relationship-role-name>many-Product@children-Have-Product</
    relationship-role-name>
    o Define <relationship-role-map> that defines the mapping of the foreign key to
    the primary key mapping
    § Example:
    <relationship-role-map>
    <column-map>
    <foreign-key-column>Parent_Product_ID</foreign-key-column>
    <key-column>Product_ID</key-column>
    </column-map>
    </relationship-role-map>
    · Specify the mapping using <weblogic-relationship-role>
    o Specify the role name matching the name in the ejb-jar
    § Example: <relationship-role-name> many-Product@parents-Have-Product</
    relationship-role-name>
    o Define <relationship-role-map> that defines the mapping of the foreign key to
    the primary key mapping
    § Example:
    <relationship-role-map>
    <column-map>
    <foreign-key-column>Child_Product_ID</foreign-key-column>
    <key-column>Product_ID</key-column>
    </column-map>
    </relationship-role-map>
    "Thomas A. Valletta" <[email protected]> wrote in message news:[email protected]...
    I am attempting to create an EJB that uses Container Managed Persistence,
    but my situation seems to be an odd one. The EJB needs to have a
    Many-to-Many relationship to itself, because the object is Hierarchical.
    Because this is my first EJB I am having a hard time with all of the
    deployment descriptors.
    I am asking for an example of any Many-to-Many EJB relationship that uses
    Weblogic's built-in link table creation to make the relationship (that
    works). I realize that there are confidentiality issues with many people
    releasing code. I will make any promise (short of selling my soul) that the
    code will be safe and promply destroyed immediately after inspection.
    Thanks for any help,
    Tom
    [email protected]
    [att1.html]
    [ejb-jar.xml]
    [weblogic-cmp-rdbms-jar.xml]
    [weblogic-ejb-jar.xml]
    [ProductBean.java]
    [ProductLocal.java]
    [ProductLocalHome.java]

  • Many-to-one relationships

    I'm trying to implement a many-to-one relationship similar to the one, for example, between an OrderLineItem and a Product.
    I managed to create the beans and define the relationship using deploytool.
    What I'm trying to understand is how can I prevent a Product instance from being deleted when it is involved in the relationship described above?
    Currently, under Sun's reference implementation server, I am allowed to delete a Product even if there are OrderLineItems that reference it.
    There is one line printed out in the window running j2ee -verbose:
    com.sun.ejb.containers.EntityContainer$EJBTxKey
    The record in the Product table is deleted nonetheless.
    Another weird thing is that the server does not allow me to deploy two beans involved in a many-to-one relationships with the Product bean if they are using the same CMR field name. What I get is a compilation error at the deployment time.
    I'd appreciate any input.

    They way I handle this is to hide the creation/manipulation/deletion of the bean behind a manager - for example a singleton session bean. I NEVER allow the direct creation/deletion of entity beans except through manager classes. This is quite a common J2EE pattern, whose name escapes me at the moment.
    Your manager would have a method like delete(int productId), which would delete the matching Product entity bean, and would then search the OrderLineItem beans for the matching Product primary key.

  • Many to one relationships strange behavior

    I have a problem with two many to one relationships.
    The problem appears from the dirty mechanism of cmr/cmp fields.
    When I have two “many-to-one” relationships ex:
    A n..1 B
    A n..1 C
    Navigability: B -> A
              A <-> C
    When I put in ejb-jar.xml the B to A relation first, the bugs appear. The dirty mechanism work chaotic. The problem is in the generated code for the PersistenceManager and Wrapper of the A bean.
    In the Wrapper the only fields with dirty mecansim are the real fields from bean which are navigable. In the PersistenceManager class are the same fields like in the BeanWrapper plus the fake fields for relationship. But the fake fields are intercalated with real fields and the dirty flag values are not the same with the dirty flags from BeanWrapper. Result: chaotic updates.
    Solution(workaround – not elegant): put first the relation which has navigability from A to C and second A to B.

    They way I handle this is to hide the creation/manipulation/deletion of the bean behind a manager - for example a singleton session bean. I NEVER allow the direct creation/deletion of entity beans except through manager classes. This is quite a common J2EE pattern, whose name escapes me at the moment.
    Your manager would have a method like delete(int productId), which would delete the matching Product entity bean, and would then search the OrderLineItem beans for the matching Product primary key.

  • Bidirectional many to many relationship ...

    Hello Friends !
    I want to mapp 2 tables in a bidirectional many to many relationship. kindly help me how can i mapp them. Do i need just LIST collection on both sides or there is something more to do.
    in entity class 1
    @ManyToMany
    private List<Entity1> OneList = new ArrayList<Entity1>();
    in Entity class 2
    @ManyToMany
    private List<Entity2> TwoList = new ArrayList<Entity2>();
    Thanks in advance
    Regards,
    Zeeshan

    Zeeshan
         Hi, For a bidirectional @ManyToMany mapping without a @JoinTable specified - you must specify which side is the owning side so that we know who is the owner of the relationship and optionally the fetchType (fetch).
    You may refer to the following tutorial that contains a bidirectional @ManyToMany from an entity to itself in my case (same principle for different entity classes).
         I arbitrarily chose one side (references) to be the owning relationship (specifies the mapping) and the other (peers) to be the inverse side - where the "mappedBy" attribute is specified that targets the owning side.
    You may use any collection for the type depending on your schema - such as whether you allow duplicates etc.. - I return a Set<Cell> collection.
    http://wiki.eclipse.org/EclipseLink/Examples/JPA/WebLogic_Web_Tutorial
    http://dev.eclipse.org/svnroot/rt/org.eclipse.persistence/trunk/examples/org.eclipse.persistence.example.jpa.server.weblogic.enterpriseEJB/ejbModule/org/eclipse/persistence/example/jpa/server/business/Cell.java
    // inverse relationship
    // m-m and 1-m do not weave by default
    @ManyToMany(mappedBy="references", fetch=FetchType.EAGER)
    private Set<Cell> peers;
    // owning relationship
    @ManyToMany(fetch=FetchType.EAGER)
    private Set<Cell> references;
    See also p.101-102 of the book "Pro EJB 3"
    http://books.google.com/books?id=fVCuB_Xq3pAC&printsec=frontcover&dq=pro+ejb3#PPA101,M1
    http://www.amazon.com/Pro-EJB-Java-Persistence-API/dp/1590596455
    thank you
    /michael
    www.eclipselink.org

Maybe you are looking for