Many-to-Many CMR

hi all,
i defined two entity beans, Quiz and Question, with many-to-many cmr and
a table named Quiz_questions_Question_quizesTable is created in the database after deployment process. the formed table columns consist of primary key of Quiz and primary key of Question, as expected. what i want to do is adding one more column to this table that shows the sequence number of the related question in the related quiz. is it possible? and how? or what should i do?
thanks in advance..

"what i want to do is adding one more column to this table that shows the sequence number of the related question in the related quiz."
Makes sense, but then the association table is no longer just an association table.
Perhaps a way to get you in the right frame of mind is, "how would you model this with just objects?"
Basically a CMR just represents an association between two objects. You would see in your revised object model that you do not have a simple n-to-n association between a Quiz objects and a Question objects.[Quiz](0..n)---->(1..n)[Question]The above (bastardized UML) model does not represent the enumeration of Question objects within the scope of a single Quiz object.
Perhaps the following is more accurate:[Quiz](1)---->(1..n)[QuizQuestion](0..n)---->(1)[Question]or                     [Question]
                          A
                          |
                          |
[Quiz](1)---->(1..n)[QuizQuestion]It is only after you have your object model that you should worry about the entity bean stuff.

Similar Messages

  • Unidirectional one-to-many CMR in OC4J 9.0.3.1699

    Hi,
    I have the following issue with the new (productiv) OC4J 9.0.3 build 020927.1699, with did not occur with
    build 020725.1695. I would like to deploy local entity beans CMRDepartment -1--n-> CMREmployee with container managed relations. Here's the relation part of ejb-jar.xml
    <ejb-relation>
    <ejb-relation-name>theEmployees2theDepartment</ejb-relation-name>
    <ejb-relationship-role>
    <ejb-relationship-role-name>theEmployees</ejb-relationship-role-name>
    <multiplicity>Many</multiplicity>
    <relationship-role-source>
    <ejb-name>CMREmployee</ejb-name>
    </relationship-role-source>
    </ejb-relationship-role>
    <ejb-relationship-role>
    <ejb-relationship-role-name>theDepartment</ejb-relationship-role-name>
    <multiplicity>One</multiplicity>
    <relationship-role-source>
    <ejb-name>CMRDepartment</ejb-name>
    </relationship-role-source>
    <cmr-field>
    <cmr-field-name>theEmployees</cmr-field-name>
    <cmr-field-type>java.util.Collection</cmr-field-type>
    </cmr-field>
    </ejb-relationship-role>
    </ejb-relation>
    Now the problem is that the depoyment generates an database table CMREmployee_cmrtest_cmrtest for CMR with a foreign key column CMRDepartment_theEmployees referencing the CMRDepartment_cmrtest_cmrtest table for the CMRDepartment bean, even though the relation is not navigable from Emp to Dept. Is this a bug or a feature? Here's the CMREmployee part of the orion-ejb-jar.xml after deployment:
              <entity-deployment name="CMREmployee" location="CMREmployee" wrapper="CMREmployeeHome_EntityHomeWrapper27" local-wrapper="CMREmployeeLocalHome_EntityHomeWrapper16" table="CMREmployee_cmrtest_cmrtest" data-source="jdbc/OracleDS" exclusive-write-access="false" locking-mode="optimistic" update-changed-fields-only="true" delay-updates-until-commit="true" min-instances-per-pk="0" max-instances-per-pk="50" disable-wrapper-cache="true">
                   <primkey-mapping>
                        <cmp-field-mapping name="id" persistence-name="id" />
                   </primkey-mapping>
                   <cmp-field-mapping name="name" persistence-name="name" />
                   <cmp-field-mapping name="theAddress">
                        <entity-ref home="CMRAddress">
                             <cmp-field-mapping name="theAddress" persistence-name="theAddress" />
                        </entity-ref>
                   </cmp-field-mapping>
                   <cmp-field-mapping name="CMRDepartment_theEmployees">
                        <entity-ref home="CMRDepartment">
                             <cmp-field-mapping name="CMRDepartment_theEmployees" persistence-name="CMRDepartment_theEmployees" />
                        </entity-ref>
                   </cmp-field-mapping>
                   <cmp-field-mapping name="theProjects">
                        <collection-mapping table="CMRProject_CMREmployee__1ftrph">
                             <primkey-mapping>
                                  <cmp-field-mapping name="CMREmployee_id">
                                       <entity-ref home="CMREmployee">
                                            <cmp-field-mapping name="CMREmployee_id" persistence-name="CMREmployee_id" />
                                       </entity-ref>
                                  </cmp-field-mapping>
                             </primkey-mapping>
                             <value-mapping type="cmrtest.CMRProjectLocal">
                                  <cmp-field-mapping name="CMRProject_id">
                                       <entity-ref home="CMRProject">
                                            <cmp-field-mapping name="CMRProject_id" persistence-name="CMRProject_id" />
                                       </entity-ref>
                                  </cmp-field-mapping>
                             </value-mapping>
                        </collection-mapping>
                   </cmp-field-mapping>
                   <finder-method>
                        <!-- Generated SQL: "SELECT o.id FROM CMREmployee_cmrtest_cmrtest o -->
                        <method>
                             <ejb-name>CMREmployee</ejb-name>
                             <method-name>findAllInstances</method-name>
                             <method-params>
                             </method-params>
                        </method>
                   </finder-method>
                   <ejb-ref-mapping name="ejb/references/theAddress/CMRAddressLocal" />
                   <ejb-ref-mapping name="ejb/references/theProjects/CMRProjectLocal" />
                   <resource-ref-mapping name="jdbc/EJBDataSource" />
                   <resource-ref-mapping name="jms/EJBQueueConnectionFactory" />
                   <resource-ref-mapping name="jms/EJBTopicConnectionFactory" />
                   <resource-env-ref-mapping name="jms/EJBQueue" />
                   <resource-env-ref-mapping name="jms/EJBTopic" />
              </entity-deployment>
    Any hints would be very wellcome.
    Regards
    Stefan

    Trond,
    when ou deploy your application, you should not need to include the orion-ejb-jar.xml.
    Also, if you have previously deployed the application, delete the application directory UNDER both applicatopn-deployments and applications. The directory will be your application's name.
    Hope this helps,
    Rob Cole
    Oracle

  • Making a Many to Many CMR in Netbeans

    Anyone have any clue how to do this?
    I have the classic three tables:
    create table user (
    id integer,
    name varchar(30)
    create table role (
    id integer,
    name varchar(30)
    create table userrole (
    userid integer,
    roleid integer
    I use NB 5 to create the User and Role beans from the Database. Then I go in to the ejb-jar.xml visual editor, create a CMR that's Many to Many, UserBean to RoleBean, create a CMR field in UserBean names roles. I leave "create CMR field" for RoleBean unchecked.
    Then I go to sun-cmp-mappings.xml and open up its editor.
    Click on UserBean, see the CMP fields all mapped. On the roles field, I click the Mapped Column drop down box and select "map relationship field". This pops up a new wizard, but I can't get Next to light up, and there's nothing in the Related Bean column of fields, and they're disabled so I can not change them.
    So, I'm kind of stuck at this point and curious if someone can step me through creating this relationship.

    With Netbeans 5.5 that's very easy, if you do not encounter bugs (it is a preview release):
    Just anotate your beans :
    class User {
    @ManyToMany(mappedBy="members")
    public Collection<Role> getRoles(){
    class User {
    @ManyToMany
    public Collection<User> getMembers(){
    Then the application server will create the tables for you

  • One-to-Many CMR problem

    I am trying to get Container Managed Relationships working with Oracle Application Server. I am sure that the problem it quite obvious to anyone who has got this working before, but after carefully following numerous examples, I still cant get them to work. I have various issues including the application server blocking when it calls the getB() method in "A" to populate the items from table "B", even though the generated SQL looks okay e.g., "select B_PK from B where (b_fk = 1)".
    I would be extremely grateful if you could point out my (hopefully obvious) mistake as I wrestled with it for the past couple of weeks.
    Any ideas?
    Cheers,
    Jonathan
    I have two tables A and B; A has a one-to-many relationship with B:
    Table A:
         A_PK          (primary key)
         A_NAME
    Table B:
         B_PK          (primary key)
         B_NAME
         B_FK          (foreign key to table A)
    My ejb-jar.xml file is:
    <ejb-jar>
    <enterprise-beans>
    <entity>
    <description>Entity Bean ( CMP )</description>
    <display-name>A</display-name>
    <ejb-name>A</ejb-name>
    <home>mypackage1.AHome</home>
    <remote>mypackage1.A</remote>
    <local-home>mypackage1.ALocalHome</local-home>
    <local>mypackage1.ALocal</local>
    <ejb-class>mypackage1.impl.ABean</ejb-class>
    <persistence-type>Container</persistence-type>
    <prim-key-class>java.lang.Long</prim-key-class>
    <reentrant>False</reentrant>
    <cmp-version>2.x</cmp-version>
    <abstract-schema-name>A</abstract-schema-name>
    <cmp-field><field-name>a_pk</field-name></cmp-field>
    <cmp-field><field-name>a_name</field-name></cmp-field>
    <primkey-field>a_pk</primkey-field>
    </entity>
    <entity>
    <description>Entity Bean ( CMP )</description>
    <display-name>B</display-name>
    <ejb-name>B</ejb-name>
    <home>mypackage1.BHome</home>
    <remote>mypackage1.B</remote>
    <local-home>mypackage1.BLocalHome</local-home>
    <local>mypackage1.BLocal</local>
    <ejb-class>mypackage1.impl.BBean</ejb-class>
    <persistence-type>Container</persistence-type>
    <prim-key-class>java.lang.Long</prim-key-class>
    <reentrant>False</reentrant>
    <cmp-version>2.x</cmp-version>
    <abstract-schema-name>B</abstract-schema-name>
    <cmp-field><field-name>b_pk</field-name></cmp-field>
    <cmp-field><field-name>b_name</field-name></cmp-field>
    <cmp-field><field-name>b_fk</field-name></cmp-field>
    <primkey-field>b_pk</primkey-field>
    </entity>
    </enterprise-beans>
    <relationships>
    <ejb-relation>
    <ejb-relation-name>A-B</ejb-relation-name>
    <ejb-relationship-role>
    <multiplicity>One</multiplicity>
    <cascade-delete/>
    <relationship-role-source>
    <ejb-name>A</ejb-name>
    </relationship-role-source>
    <cmr-field>
    <cmr-field-name>b</cmr-field-name>
    <cmr-field-type>java.util.Collection</cmr-field-type>
    </cmr-field>
    </ejb-relationship-role>
    <ejb-relationship-role>
    <multiplicity>Many</multiplicity>
    <relationship-role-source>
    <ejb-name>B</ejb-name>
    </relationship-role-source>
    </ejb-relationship-role>
    </ejb-relation>
    </relationships>
    </ejb-jar>
    And my orion-ejb-jar.xml file is:
    <?xml version = '1.0' encoding = 'windows-1252'?>
    <!DOCTYPE orion-ejb-jar PUBLIC "-//Evermind//DTD Enterprise JavaBeans 1.1 runtime//EN" "http://xmlns.oracle.com/ias/dtds/orion-ejb-jar.dtd">
    <orion-ejb-jar>
    <enterprise-beans>
    <entity-deployment name="A" copy-by-value="false" data-source="jdbc/Connection1DS" exclusive-write-access="false" table="a">
    <primkey-mapping>
    <cmp-field-mapping name="a_pk" persistence-name="a_pk"
    persistence-type="int(11)"/>
    </primkey-mapping>
    <cmp-field-mapping name="a_pk" persistence-name="a_pk"
    persistence-type="int(11)"/>
    <cmp-field-mapping name="a_name" persistence-name="a_name"
    persistence-type="varchar(100)"/>
    <cmp-field-mapping name="b">
    <collection-mapping table="B">
    <primkey-mapping>
    <cmp-field-mapping name="b_fk" persistence-name="B_FK"/>
    </primkey-mapping>
    <value-mapping type="mypackage1.BLocal">
    <cmp-field-mapping>
    <entity-ref home="B">
    <cmp-field-mapping name="b_pk" persistence-name="B_PK"/>
    </entity-ref>
    </cmp-field-mapping>
    </value-mapping>
    </collection-mapping>
    </cmp-field-mapping>
    </entity-deployment>
    <entity-deployment name="B" copy-by-value="false" data-source="jdbc/Connection1DS" exclusive-write-access="false" table="b">
    <primkey-mapping>
    <cmp-field-mapping name="b_pk" persistence-name="b_pk"
    persistence-type="int(11)"/>
    </primkey-mapping>
    <cmp-field-mapping name="b_pk"
    persistence-name="b_pk" persistence-type="int(11)"/>
    <cmp-field-mapping name="b_fk" persistence-name="b_fk"
    persistence-type="int(11)"/>
    </entity-deployment>
    </enterprise-beans>
    <assembly-descriptor>
    <default-method-access>
    <security-role-mapping impliesAll="true" name="&lt;default-ejb-caller-role>"/>
    </default-method-access>
    </assembly-descriptor>
    </orion-ejb-jar>

    Ok, I found out something strange. If I do the addPet operation twice in the client the new relationship is created, too.
    p = home.create("Violetta");
    p.addNewPet("Jenny");
    p = home.create("Frank");
    p.addPet("Jenny");
    p.addPet("Jenny");
    May this be a timing problem? Or is there a command I could execute to ensure all data manipulation is populated to the DB. (Like close() in JDBC)
    TIA
    Frank

  • Ejbgen: bug in many-to-many cmp

    I am trying to use ejbgen to generate the code for many-to-many cmr relationships.
    I have come across a bug where the ejb-jar.xml generates a non compliant ejb2.0 xml tag. The actual tag should be
    <relationship-role-source> however, it generates <role-source>.

    Saurabh Gupta <[email protected]> wrote in
    news:[email protected]:
    I am trying to use ejbgen to generate the code for many-to-many cmr
    relationships.
    I have come across a bug where the ejb-jar.xml generates a non
    compliant ejb2.0 xml tag. The actual tag should be
    <relationship-role-source> however, it generates <role-source>. Can you post (or email me) your two sources?
    Thanks.
    Cedric
    http://beust.com/weblog

  • Problem Removing CMP 2.0 Bean from Many side of One-to-Many

    I'm getting an exception within the weblogic container when I try to
    delete a bean from the many side of a one-to-many CMR.
    The two entity beans are called CaseFile and CaseExpert. There are
    many CaseExperts for each CaseFile. When you call the remove method
    on the CaseExpert, Weblogic throws a null pointer exception when
    accessing the EntityCache as shown at the bottom of this message. I'm
    using the latest version of Weblogic 7 (WebLogic Server 7.0 Thu Jun
    20 11:47:11 PDT 2002 190955). My relationship section of my
    ejb-jar.xml file is also shown below.
    Any ideas?
    Thanks,
    David
    [email protected]
    javax.ejb.EJBException: EJB Exception:: java.lang.NullPointerException
    at weblogic.ejb20.cache.TxKey.<init>(TxKey.java:30)
    at weblogic.ejb20.cache.EntityCache.doGet(EntityCache.java:158)
    at weblogic.ejb20.cache.EntityCache.get(EntityCache.java:118)
    at weblogic.ejb20.manager.DBManager.getReadyBean(DBManager.java:252)
    at weblogic.ejb20.manager.DBManager.lookup(DBManager.java:949)
    at gov.usdoj.usa.ecms.casefile.exposure.ejb.CaseExpertBean_76ewyr__WebLo
    gic_CMP_RDBMS.__WL_setCaseFile(CaseExpertBean_76ewyr__WebLogic_CMP_RDBMS.java:45
    2)
    at gov.usdoj.usa.ecms.casefile.exposure.ejb.CaseExpertBean_76ewyr__WebLo
    gic_CMP_RDBMS.__WL_setCaseFile(CaseExpertBean_76ewyr__WebLogic_CMP_RDBMS.java:43
    1)
    at gov.usdoj.usa.ecms.casefile.exposure.ejb.CaseExpertBean_76ewyr__WebLo
    gic_CMP_RDBMS.ejbRemove(CaseExpertBean_76ewyr__WebLogic_CMP_RDBMS.java:1978)
    at weblogic.ejb20.manager.DBManager.remove(DBManager.java:876)
    at weblogic.ejb20.internal.EntityEJBLocalObject.remove(EntityEJBLocalObj
    ect.java:95)
    <relationships>
    <ejb-relation>
    <ejb-relation-name>caseExpert-caseFile</ejb-relation-name>
    <ejb-relationship-role>
    <ejb-relationship-role-name>CaseExpert-CaseFile</ejb-relationship-role-name>
    <multiplicity>many</multiplicity>
    <relationship-role-source>
    <ejb-name>CaseExpertEJB</ejb-name>
    </relationship-role-source>
    <cmr-field>
    <cmr-field-name>caseFile</cmr-field-name>
    </cmr-field>
    </ejb-relationship-role>
    <ejb-relationship-role>
    <ejb-relationship-role-name>CaseFile-CaseExperts</ejb-relationship-role-name>
    <multiplicity>one</multiplicity>
    <relationship-role-source>
    <ejb-name>CaseFileEJB</ejb-name>
    </relationship-role-source>
    <cmr-field>
    <cmr-field-name>caseExperts</cmr-field-name>
    <cmr-field-type>java.util.Collection</cmr-field-type>
    </cmr-field>
    </ejb-relationship-role>
    </ejb-relation>
    </relationships>

    Wrong newsgroup, needs to go to one of the ejb newsgroups.
    mbg
    "Sai S Prasad" <[email protected]> wrote in message
    news:3ec28167$[email protected]..
    >
    Hi,
    I like to do the following:
    1) Map one bean corresponding to table A to many beans corresponding totable
    B 2) table B has two columns as the primary keys.
    3) One of the primary key column in table B is a foreign key pointing tothe primary
    key of table A.
    4) bean corresponding to table A has the cmr Collection field
    I am not able to map this scenario. I guess the mapping is possible aslong as
    each table has its own unrelated primary keys. If anyone has tried this,please...please...help.
    >
    >
    Thanks.

  • One-to many relationship in EJB

    hi forum
    wish you a very happy and prosperous new year
    i want to implement CMR in my project but to start with i tried sample application setting one-to many CMR between EMP and DEPT table of scott/tiger .the problem is i have to modify my orion-ejb-jar.xml how can we do it?

    Are you using JDeveloper? JDeveloper automatically creates the orion-ejb-jar.xml file when you use the EJB wizard.

  • EJB 2.0 RI, CMR, problem with one-to-many

    I got an entity bean with a one/many, bidirectional, non-cascading relationship to another entity bean. The "one" side is represented by the remote type of the related entity bean.
    The "many" side is represented by the type "java.util.Collection".
    Unfortunately, the Verifier spits out the following error for the "many" side:
    Error : Invalid type assigned for container managed field [ depots ] in bean [ Account ]
    "depots" is defined in AccountEJB.java via the abstract contract
    [import java.util.Collection;]
    public abstract Collection getDepots();
    public abstract void setDepots(Collection depots);
    Q1. Is there anything wrong with this?
    Q2. Does the currect J2EE RI 1.3 beta support CMR as defined in the draft2 of EJB 2.0?
    Q3. Do I need to mark the CMR fields as CMP 2.0 ("fields to be persisted") in the Deployment Tool? I'd say yes, but if I would be picky, CMR would not be CMP...
    Q4. Can anyone point me to a good example of CMR. The PetStore App uses BMP everywhere, and I could not find any other useful demos.
    I'd appreciate any help!
    Greetings,
    Andreas

    I am new to J2SDKEE1.3 CMR. I have similar question about CMR. The only example is the "customer" under the J2SDKEE1.3 doc fold. Can anyone provide more examples?
    Thanks in Advance.
    Oliver

  • CMR Many-to-Many Question

    Hi,
    I am doing an applicatiion using CMP. I have 2 tables in my database that have a many-to-many unidirectional relationship. Consequently, I have created a link table that takes the primary key value from both tables. It is the standard way for doing it in a relational databse. I have setup CMR fields in my appropriate bean class. My question is, will that link table be updated by the container when I create a new relationship?
    I have looked at the folowing code from the IBM website. I think it is a good example.
    The addRole() adds a role to a UserBean as follows:
    public void addRole(String email, String roleName){
        LocalUser user = userHome.findByPrimaryKey(email);
        LocalRole role = roleHome.findByPrimaryKey(roleName);
        Collection roles = user.getRoles();
        roles.add(role); The author the says "Thus, when a role gets added to the roles collection, the EJB container updates the datastore. Thus, the code that inserts the relationship in the datastore is the interface of the Collection class."
    Does he mean that a link table will be updated?
    If anyone has tried this could they please let me know.
    Thanks,
    Chris.

    Yeh I know I don't have to write to the database, but when I create my CMP bean I didnt map it to my link table. Therefore I'm not sure if the container will update the link table in my database.

  • Ejb,cmr many to one

    hi,
    i have two tables department and employee.The employee table contains the foreign key dept_id.When i am trying to insert it doesnot insert the foreign key in the Employee table.Can anyone give an example program along with the ejb-jar.xml and sun-cmp-mappings.xml file
    thank u

    This is the excerpt of ejb-jar.xml:
    <ejb-jar>
    <relationships>
    <description>Department-Employee</description>
    <ejb-relation>
    <description>Department-Employee</description>
    <ejb-relation-name></ejb-relation-name>
    <ejb-relationship-role>
    <ejb-relationship-role-name>DepartmentEJB</ejb-relationship-role-name>
    <multiplicity>One</multiplicity>
    <relationship-role-source>
    <ejb-name>DepartmentEJB</ejb-name>
    </relationship-role-source>
    <cmr-field>
    <cmr-field-name>employees</cmr-field-name>
    <cmr-field-type>java.util.Collection</cmr-field-type>
    </cmr-field>
    </ejb-relationship-role>
    <ejb-relationship-role>
    <ejb-relationship-role-name>EmployeeEJB</ejb-relationship-role-name>
    <multiplicity>Many</multiplicity>
    <cascade-delete />
    <relationship-role-source>
    <ejb-name>EmployeeEJB</ejb-name>
    </relationship-role-source>
    <cmr-field>
    <cmr-field-name>department</cmr-field-name>
    </cmr-field>
    </ejb-relationship-role>
    </ejb-relation>
    </relationships>
    </ejb-jar>
    This is the excerpt from sun-cmp-mappings.xml:
    <sun-cmp-mappings>
    <sun-cmp-mapping>
    <entity-mapping>
    <ejb-name>DepartmentEJB</ejb-name>
    <table-name>DEPARTMENT</table-name>
    <cmr-field-mapping>
    <cmr-field-name>employees</cmr-field-name>
    <column-pair>
    <column-name>DEPARTMENT.ID</column-name>
    <column-name>EMPLOYEE.DEPT_ID</column-name>
    </column-pair>
    </cmr-field-mapping>
    </entity-mapping>
    <entity-mapping>
    <ejb-name>EmployeeEJB</ejb-name>
    <table-name>EMPLOYEE</table-name>
    <cmr-field-mapping>
    <cmr-field-name>department</cmr-field-name>
    <column-pair>
    <column-name>EMPLOYEE.DEPT_ID</column-name>
    <column-name>DEPARTMENT.ID</column-name>
    </column-pair>
    </cmr-field-mapping>
    </entity-mapping>
    </sun-cmp-mapping>
    </sun-cmp-mappings>
    Both excerpts show only the parts relevant to the relationship btw. employee-department.

  • Primary key is null in CMP ejbLoad()

    Using WebLogic 7.0 with Oracle 9i Lite.
    We're logging the values of the CMP fields in ejbLoad(). All of the
    CMP values look fine, except for the primary key value; it's always
    null. This means that Foo.getKey() (the CMP field that returns the
    primary key value) always returns null.
    Foo.getPrimaryKey() works as expected.
    This appears to be causing problems with CMR fields. The Collection
    we get from a "many" CMR field is populated with the correct number of
    elements, but if we try to remove one of them we're getting a "primary
    key cannot be null" exception from the container.
    Any insights?
    Richard A. Steele
    Paychex

    Here's some more information:
    We're able to successfully create entity beans; for example, we have beans OrganizationEJB
    and BusinessSiteEJB. There's a one-to-many relationship from OrganizationEJB to
    BusinessSiteEJB.
    Because of database integrity constraints, when we create a BusinessSite, we have
    to provide the Organization as a parameter to create(). This works fine--after calling
    create(), I see the new BusinessSite in the database.
    We can also do a findByPrimaryKey() on BusinessSite and retrieve the business site.
    However, if I do a getBusinessSites() on Organization, I get back a Collection, but:
    1. Sometimes it has just a single entry, even if we know there are multiple business
    sites for this organization. Sometimes, it has the right number of entries, but
    every one of them is identical.
    2. The primary key of the entries in the Collection are all null. In other words,
    if I do a getPrimaryKey() on the BusinessSite local interfaces in the collection,
    I get back null.
    3. If I try to delete any of the Business Sites in the collection, the container
    throws an exception that the primary key can't be null.
    Richard A. Steele
    Paychex

  • EJBGen start method error

    Hi,
    I am getting this error while trying to create a sample bean using EJBGen.
    1. I have added the ejbgen.jar to the classpath.
    2. I have set the classpath to the current dir where the AccountBean.java is present.
    I have used the following code in AccountBean.java
    * @ejbgen:entity
    * ejb-name = AccountEJB-OneToMany
    * data-source-name = examples-dataSource-demoPool
    * table-name = Accounts
    * prim-key-class = java.lang.String
    * @ejbgen:jndi-name
    * local = one2many.AccountHome
    * @ejbgen:finder
    * signature = "Account findAccount(double balanceEqual)"
    * ejb-ql = "WHERE balance = ?1"
    * @ejbgen:finder
    * signature = "Collection findBigAccounts(double balanceGreaterThan)"
    * ejb-ql = "WHERE balance > ?1"
    * @ejbgen:relation
    * name = Customer-Account
    * target-ejb = CustomerEJB-OneToMany
    * multiplicity = many
    * cmr-field = customer
    import javax.ejb.*;
    import com.sun.javadoc.*;
    abstract public class AccountBean implements EntityBean {
         * @ejbgen:cmp-field column = acct_id
         * @ejbgen:primkey-field
         * @ejbgen:remote-method transaction-attribute = Required
         abstract public String getAccountId();
         abstract public void setAccountId(String val);
    I am getting the following error.
    C:\>javadoc -docletpath ejbgen.jar -doclet weblogic.tools.ejbgen.EJBGen AccountBean.java
    Loading source file AccountBean.java...
    Constructing Javadoc information...
    javadoc: Doclet class weblogic.tools.ejbgen.EJBGen does not contain a start method
    1 error
    I have checked the EJBGen class file and the start method is present in it. Please suggest if I am missing anything.
    thanks,
    Srikanth.

    even i got the same error, where you able to fix it ?
    i am using weblogic 9.2

  • Collection in order

    hi all,
    i have a one-to-many cmr from Anket entity bean to Bolum entity bean.
    public class BolumType implements java.io.Serializable{
         public Integer anketID, bolumID;
         public BolumType(Integer anketID, Integer bolumID){
              this.anketID = anketID;
              this.bolumID = bolumID;
    public abstract class Bolum implements EntityBean{
            public abstract BolumType getBolumID(); // primary key
            public abstract void setBolumID(BolumType id);
            public abstract String getBolumName();
            public abstract void setBolumName(String name);
    public abstract class Anket implements EntityBean{
         public abstract Collection getBolums();
         public abstract void setBolums(Collection bolums);
         public ArrayList getBolumList(){
              ArrayList list = new ArrayList();
              Iterator b = getBolums().iterator();
              while(b.hasNext())
                   list.add((LocalBolum)b.next());
              return list;
    }calling the getBolumList() method from the local interface of the Anket bean brings the collection of bolums in disorder.. i want to retrieve the collection of bolums in order of bolumID defined in BolumType class.. i suppose i have to use an ejbSelect method..
    public abstract class Anket implements EntityBean{
         public abstract Collection ejbSelectBolumsInOrder();
         public ArrayList getBolumList() throws FinderException{
              ArrayList list = new ArrayList();
              Iterator b = ejbSelectBolumsInOrder().iterator();
              while(b.hasNext())
                   list.add((LocalBolum)b.next());
              return list;
    }(i'm not sure whether above implementation is correct)
    but if so, how can i reach bolumID defined in BolumType class with EJB-QL? or what should i do?
    thanks in advance..

    In your ejb-jar.xml you should have the SQL code for the queries that are being executed against the DB for each EJB. There you can modify the SQL code to execute with the Order by option, which would return an ordered resultset.
    Regards,
    Dimitar

  • EJBGen bug

    I'm having the following problem with WebLogic 9.1 EJBGen- whenever using it in an EJB that has static imports it throws a NullPointerException. I'm not sure if someone else experienced this problem, but it seems to be a bug.

    Saurabh Gupta <[email protected]> wrote in
    news:[email protected]:
    I am trying to use ejbgen to generate the code for many-to-many cmr
    relationships.
    I have come across a bug where the ejb-jar.xml generates a non
    compliant ejb2.0 xml tag. The actual tag should be
    <relationship-role-source> however, it generates <role-source>. Can you post (or email me) your two sources?
    Thanks.
    Cedric
    http://beust.com/weblog

  • EjbActivate() and ejbPassivate() methods are called million times!!! :(

    Hello All,
    Am I missing some thing here?
    We have a project with many Entity Beans, and all of them have relations with one another. The simple example I can give is Entity A has one to many relation with Entity B.
    i.e There could be one Entity A and for this there could be many Entities B these two entities are managed by CMR fields.
    Entity A has a PK, this would act as a FK in Entity B.
    In the EJB Post create method of Entity B I am trying to find a suitable entity A and trying to execute setEntityA(suitableEntityA), while this method is getting executed here is the things that happen
    the container tries to find all Entity B (if there are 10,000 records in B table then ejbActivate() of B is executed 10,000 times) then it sets the relation with Entity A, then at the end of the Transaction the container will call ejbPassivate() method on Entity B 10,000 times!!! oh god what is happening here...!!!?????
    can some one tell me if I am missing some settings?
    The same thing happends for all the other EJBs which have one to many CMR fields, i.e ejbActivate() and ejbPassivate() of each of these Entity Beans will be called for those many number of times for as many records found in the Datbase of the corresponding Entity.
    I have the follwing setting in my orion-ejb-jar.xml file
    <entity-deployment name="EntityA"
    max-tx-retries="0"
    max-instances="-1"
    location="EntityA"
    table="A"
    data-source="jdbc/oracleDS"
    exclusive-write-access="false"
    locking-mode="optimistic"
    update-changed-fields-only="true"
    delay-updates-until-commit="true">
    similar xml construct for Entity B also!!!
    If some one knows more about this please let me know.
    Thank you
    -Mallik

    Found one more thing for this CMP-CMR relationship and ejbActivate() and ejbPassivate() process of CMP Entity's.
    In this above example if say
    Entity A (Dept) ------ Entity B (Employee) (1:M) has one to many relationship
    Employee holds a FK value which is PK in Dept (dept_id).
    Suppose asssume that there are 10,000 employees working for a dept_id = 5.
    (i.e there are 10,000 records in Employee that references Dept table with dept_id =5)
    Now I want to add one more employee to this dept_id = 5, then I create an Employee entity and in the ejbPostCreate() method of Employee entity I lookup Dept Entity with Dept_PK=5, until this every thing is fine. Now I call setter method with in Employee Entity to set the dept such as setDept_dept_id(detpEntity5), at the execution of this method EJB container calls starts calling Employee Entity's the ejbActivate() method for 10,000 times this equals the number of references Employee table has to Dept table with Dept_ID=5, then at the end of the transaction the container calls ejbPassivate() method 10,000 times to passivate all those ejbs that it activated.
    Did some one experience the same thing with CMP EJBs? please let me know what I have to do to avoid such things?
    Thank you
    Mallik

Maybe you are looking for

  • Service Issue Of Xperia Z3 Compact

    SONY MOBILE COMPLIANT - W115061501443 Hi, I purchased Sony Xperia Z3 Compact hardly 6 months back for 39000 INR. On 15 June 2015 my phone got dead suddenly. i have submitted my phone immediately to the service center on 15 june 2015. in 12 days my ph

  • I Need to Write the current Date and Time

    I need to write the current date and time to calculate the spend time in each instruction. What is the instrucion? Thanks. MIGUEL ANGEL CARO [email protected]

  • Client-server database application...

    Hi there! I'm about to write a database-application and I wonder if the following approach is to prefer or not: I want to use a MySQL-database and there shall be about eight client-applications which all shall be able to use it. I think of solving th

  • Undo undoes too many steps - help!

    Can someone please explain to me how Undo works in CS4? I'll be working along, make a mistake, and when I hit CTRL-Z, I lose several steps in my process, not just the most recent one. Is there some kind of Undo setting that I can change so that it is

  • Dp90 - mb1a

    Hi everybody We are using DP90 to bill the movements done with MB1A. The system is taking the date of today to calculate the price. We can not use the field "pricing date" in DP90 screen because in the same sd documents can be billed movements done i