CMP relationships

Good day all. I have a question about establishing 1:M relationship in CMP.
More specifically I am geting the following error
[EJB:011017]Error while reading 'META-INF/weblogic-cmp-rdbms-jar.xml'. The error was:
In relationship 'THREAD-POST', role 'Thread-Contains-Posts', a weblogic-relationship-role element contains the wrong number of column mappings. A single column mapping must be given for each primary key column in the bean referenced by the mapping.
Here is my ejb-jar code
<ejb-relation>
<ejb-relation-name>THREAD-POST</ejb-relation-name>
<ejb-relationship-role>
<ejb-relationship-role-name>Thread-Contains-Posts</ejb-relationship-role-name>
<multiplicity>One</multiplicity>
<relationship-role-source>
<ejb-name>Thread</ejb-name>
</relationship-role-source>
<cmr-field>
<cmr-field-name>posts</cmr-field-name>
<cmr-field-type>java.util.Collection</cmr-field-type>
</cmr-field>
</ejb-relationship-role>
<ejb-relationship-role>
<ejb-relationship-role-name>Post-Resides-in-Thread</ejb-relationship-role-name>
<multiplicity>Many</multiplicity>
<cascade-delete/>
<relationship-role-source>
<ejb-name>Post</ejb-name>
</relationship-role-source>
<cmr-field> <cmr-field-name>localthread</cmr-field-name>
</cmr-field>
</ejb-relationship-role>
</ejb-relation>
and weblogic code
<weblogic-rdbms-relation>
<relation-name>THREAD-POST</relation-name>
<weblogic-relationship-role>
<relationship-role-name>Thread-Contains-Posts</relationship-role-name>
<relationship-role-map>
<foreign-key-table>POST</foreign-key-table>
<primary-key-table>THREAD</primary-key-table>
<column-map>
<foreign-key-column>thread</foreign-key-column>
<key-column>id</key-column>
</column-map>
</relationship-role-map>
</weblogic-relationship-role>
</weblogic-rdbms-relation>
Bean Thread has PK id which is matched to a foreign key thred in the Post bean.
Where did it all go so wrong?
Bean Post has attributes id(PK),text,

hi,
can you able to post your code so that i can try
with it.

Similar Messages

  • Deploying CMP Relationships

    Hi I wonder if someone could help me please. Im trying to deploy an EJB CMP Relationship example. In fact the one from Enterprise JavaBeans by R. Monson-Haefel Example 6.3. Now I realise there was some code missing to do with throwing Exceptions, which I've added - so its not the pure example.
    Right so I'm using j2eesdk 1.3.1 along with Cloudscape as the DB and the standard J2ee deployment tool.
    My first problem is that when I try to setup the relationship between the Customer & the Address I only get the Customer Bean in the 'Edit Relationship' Dialogue Box - not the Address as well. Yep I've deployed the Address EJB.
    Then when I validate the EJB I get the following logged to the Resaults file
         Test Name : tests.ejb.entity.TransactionDemarcationHomeInterface
         Test Assertion : Entity bean container transaction demarcation for methods of home interface test
         Test Description : For [ CustomerBean ]
    Error: Transaction attributes must be specified for the methods defined in the home interface [ com.titan.customer.CustomerHomeRemote ]. Method [ create ] has no transaction attribute defined within this bean [ CustomerBean ].
    I've set the transaction attributes to 'Requires New' but it doesn't seem to be saving then to the Deployment file.
    Thanks & Regards
    Nick

    Oops, I've fixed the problem by re-reading the manuals yet again. I missed the line that said that both of the EJB needed to be in the SAME jar file not just the same package.
    Nick

  • CMP relationship requires constraint???

    I'm currently using WSAD to develop some EntityBeans using CMP, and I've discovered that the mapping tool in WSAD won't let me map entity bean relationships to the database unless there is a foreign key constraint implemented in the database (the tables has columns representing foreign keys, but there is no foreing key constraint between the tables).
    Is this according to the EJB2.0 spec. or is it just an extra "feature" from IBM?

    Did some testing, and it turns out that it's the WSAD mapping tool that needs the foreign key constraint in the DB to set up the relation mappings between the Entity Beans.
    The workaround, when using "meet in the middle" mapping strategy, is to let the mapping tool generate the db schema from the excisting database, and then add foreign key constraints to the reveresed schema during the mapping - and finally deploy the bean without forwarding the schema in WSAD to the database. This seems to work fine...

  • One to one CMP relationship... Table Structure

    Table : Person
    Person_ID
    First_Name
    Last_Name
    Table:Role
    Person_ID
    Role_Name
    Role_Details

    Hi,
    Circular relationship are never supported by any server, an example would be
    A has a relation with B, B has a relation with C, and C to A
    Self relation means A has a relation with its own kind (A).
    If a bean A has relation with B and B has relation with A, you dont call it circular its bidirectional relation.
    Basically directionality depends how do you want to navigate your relations, viz., which bean needs to keep track of which bean.
    Regards
    Meka Toka
    PS: And yeah, environment means, what server you are using, what OS, what version number etc etc.

  • Ejb relationships using cmp field

    I have defined a cmp relationship using cmr field. Als defined getter/setter for that field.
    When I call the getter method container returns all the records for relation.
    getter/setter is implemented by container.
    My question is can we define in which order relationships record should be retrieved. I mean can we specify Order By caluse for that.

    if you want to do this you just have to use Map on collection side of your relationship like this:
    @OneToMany(cascade={CascadeType.ALL})
        @JoinColumn(name="CUSTOMER_ID")
    @MapKey(name="number")
    @OrderBy
    ("number ASC")
        public Map<String, Phone> getPhoneNumbers

  • Defining cmp-relation to EB contained in different ejb module project

    Hello,
    I have to migrate an existing J2EE Application to SAP NetWeaver and WebAS. My task is to keep the structure as similar as possible to increase the recognition factor although using Developer Studio as IDE.
    In this application there are cmp relations defined that reference EntityBeans from other sub projects (that I tried to create in different ejb module projects).
    References in the same ejb module project seem to work fine but I cannot select referenced EntityBeans of other projects as relation target.
    Another remark:
    In the given application the ejb-jar.xml-file of the referencing component contains entries of the referenced one. The Developer Studio allows to Add EJBs to ejb-jar.xml, even referenced Beans. But when I select to add referenced EJBs only the Beans of the current project can be chosen. (I did not forget to enter an ejb-local-ref from the referencing to the referenced Bean in ejb-jar.xml as well)
    Can anyone give me a hint on how to solve this task? Or where I have forgotten to add a reference?
    Thanks
    Daniel

    Hello Viliana,
    Hello everybody else!
    I'm currently writing the corresponding masterthesis to my project. That's why I have to deal with this "problem" again.
    I tried to look up the part of the spec Viliana's hint ("When you create and use cmp-relationships your beans must be included in one and the same JAR file (that's according to the EJB specification)") bases on.
    But the only thing I found addressing this issue tells something else:
    "[...]Container-managed relationships can exist only among entity beans within the same local relationship
    scope,[...]" (EJBSpec2.1, section 10.3.2)
    In my opinion this does not necessarily mean that they have to be in the same JAR but in the same EAR file...
    This would mean, that the chosen cmp-relationships strategy with ejb-module-projects is too restrictive.
    Can anyone help me with this... Does anyone know further hints on how Entity Beans have to be deployed when belonging to cmp-relationships?
    Thanks a lot for any hint on this
    Best regards,
    Daniel

  • Cmp dependant object

    does anybody have a working example of a ejb20 bean that uses dependant
    objects with a CMP relationship. I am trying to do a simple relationship
    where an ejb has a Collection of dependant objects.
    I cant get past the xml parsing errors when ejbc is run.
    The error is
    ERROR: weblogic.xml.process.XMLParsingException: The content of element
    type "ej
    b-jar" must match
    "(description?,display-name?,small-icon?,large-icon?,enterpris
    e-beans,dependents?,relationships?,assembly-descriptor?,ejb-client-jar?)".
    - wit
    h nested exception:
    [org.xml.sax.SAXParseException: The content of element type "ejb-jar"
    must match
    "(description?,display-name?,small-icon?,large-icon?,enterprise-beans,dependent
    s?,relationships?,assembly-descriptor?,ejb-client-jar?)".] Line: 152
    Column: 11
    here is the ejb-jar.xml file:
    <?xml version="1.0"?>
    <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise
    JavaBeans 2.0//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_2_0.dtd">
    <ejb-jar>
    <enterprise-beans>
    <entity>
    <ejb-name>SurveyEJB</ejb-name>
    <home>erm.com.clickaction.erm.surveys.ejb20.SurveyHome</home>
    <remote>erm.com.clickaction.erm.surveys.ejb20.Survey</remote>
    <ejb-class>erm.com.clickaction.erm.surveys.ejb20.SurveyBean</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>SurveyBean</abstract-schema-name>
    <cmp-field>
    <field-name>surveyKey</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>clientKey</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>name</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>description</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>version</field-name>
    </cmp-field>
    <primkey-field>surveyKey</primkey-field>
    <query>
    <query-method>
    <method-name>findAllSurveys</method-name>
    <method-params/>
    </query-method>
    <ejb-ql><![CDATA[WHERE surveyKey is not null]]></ejb-ql>
    </query>
    </entity>
    <entity>
    <ejb-name>TopicEJB</ejb-name>
    <home>erm.com.clickaction.erm.surveys.ejb20.TopicHome</home>
    <remote>erm.com.clickaction.erm.surveys.ejb20.Topic</remote>
    <ejb-class>erm.com.clickaction.erm.surveys.ejb20.TopicBean</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>TopicBean</abstract-schema-name>
    <cmp-field>
    <field-name>topicKey</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>name</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>description</field-name>
    </cmp-field>
    <primkey-field>topicKey</primkey-field>
    <query>
    <query-method>
    <method-name>findAllTopics</method-name>
    <method-params/>
    </query-method>
    <ejb-ql><![CDATA[WHERE topicKey is not null]]></ejb-ql>
    </query>
    </entity>
    </enterprise-beans>
    <assembly-descriptor>
    <container-transaction>
    <method>
    <ejb-name>SurveyEJB</ejb-name>
    <method-intf>Remote</method-intf>
    <method-name>*</method-name>
    </method>
    <trans-attribute>Required</trans-attribute>
    </container-transaction>
    <container-transaction>
    <method>
    <ejb-name>TopicEJB</ejb-name>
    <method-intf>Remote</method-intf>
    <method-name>*</method-name>
    </method>
    <trans-attribute>Required</trans-attribute>
    </container-transaction>
    </assembly-descriptor>
    <dependents>
    <dependent>
    <description>Topic</description>
    <dependent-class>erm.com.clickaction.erm.surveys.ejb20.Topic</dependent-class>
    <dependent-name>Topic</dependent-name>
    <cmp-field><field-name>topicKey</field-name></cmp-field>
    <cmp-field><field-name>name</field-name></cmp-field>
    <cmp-field><field-name>description</field-name></cmp-field>
    <pk-field>topicKey</pk-field>
    </dependent>
    </dependents>
    <relationships>
    <ejb-relation>
    <ejb-relation-name>Survey-Topic</ejb-relation-name>
    <ejb-relationship-role>
    <ejb-relationship-role-name>survey-has-topics</ejb-relationship-role-name>
    <multiplicity>one</multiplicity>
    <role-source><ejb-name>SurveyEJB</ejb-name></role-source>
    <cmr-field>
    <cmr-field-name>topics</cmr-field-name>
    <cmr-field-type>java.util.Collection</cmr-field-type>
    </cmr-field>
    </ejb-relationship-role>
    <ejb-relationship-role>
    <ejb-relationship-role-name>topics-belongto-survey</ejb-relationship-role-name>
    <multiplicity>many</multiplicity>
    <cascade-delete/>
    <role-source><dependent-name>TopicEJB</dependent-name></role-source>
    <cmr-field>
    <cmr-field-name>survey</cmr-field-name>
    </cmr-field>
    </ejb-relationship-role>
    </ejb-relation>
    </relationships>
    </ejb-jar>
    thanks
    simon evans
    [email protected]

    Hi Simon,
    I'm reposting your message to the ejb group where you can get more help. This group
    is monitored more for issues regarding general product usability feedback, rather
    than "how to" issues.
    However, I do see you've uncovered a usability issue in as much as you couldn't find
    appropriate documentation or examples to help understand the problem. Moreover, you
    weren't able to figure out what to do next using the ejbc compiler error messages.
    I'll take a look at the problem from this point of view.
    In the mean time, ejb team, can you lend a hand?
    dan
    simon wrote:
    does anybody have a working example of a ejb20 bean that uses dependant
    objects with a CMP relationship. I am trying to do a simple relationship
    where an ejb has a Collection of dependant objects.
    I cant get past the xml parsing errors when ejbc is run.
    The error is
    ERROR: weblogic.xml.process.XMLParsingException: The content of element
    type "ej
    b-jar" must match
    "(description?,display-name?,small-icon?,large-icon?,enterpris
    e-beans,dependents?,relationships?,assembly-descriptor?,ejb-client-jar?)".
    - wit
    h nested exception:
    [org.xml.sax.SAXParseException: The content of element type "ejb-jar"
    must match
    "(description?,display-name?,small-icon?,large-icon?,enterprise-beans,dependent
    s?,relationships?,assembly-descriptor?,ejb-client-jar?)".] Line: 152
    Column: 11
    here is the ejb-jar.xml file:
    <?xml version="1.0"?>
    <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise
    JavaBeans 2.0//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_2_0.dtd">
    <ejb-jar>
    <enterprise-beans>
    <entity>
    <ejb-name>SurveyEJB</ejb-name>
    <home>erm.com.clickaction.erm.surveys.ejb20.SurveyHome</home>
    <remote>erm.com.clickaction.erm.surveys.ejb20.Survey</remote>
    <ejb-class>erm.com.clickaction.erm.surveys.ejb20.SurveyBean</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>SurveyBean</abstract-schema-name>
    <cmp-field>
    <field-name>surveyKey</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>clientKey</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>name</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>description</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>version</field-name>
    </cmp-field>
    <primkey-field>surveyKey</primkey-field>
    <query>
    <query-method>
    <method-name>findAllSurveys</method-name>
    <method-params/>
    </query-method>
    <ejb-ql><![CDATA[WHERE surveyKey is not null]]></ejb-ql>
    </query>
    </entity>
    <entity>
    <ejb-name>TopicEJB</ejb-name>
    <home>erm.com.clickaction.erm.surveys.ejb20.TopicHome</home>
    <remote>erm.com.clickaction.erm.surveys.ejb20.Topic</remote>
    <ejb-class>erm.com.clickaction.erm.surveys.ejb20.TopicBean</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>TopicBean</abstract-schema-name>
    <cmp-field>
    <field-name>topicKey</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>name</field-name>
    </cmp-field>
    <cmp-field>
    <field-name>description</field-name>
    </cmp-field>
    <primkey-field>topicKey</primkey-field>
    <query>
    <query-method>
    <method-name>findAllTopics</method-name>
    <method-params/>
    </query-method>
    <ejb-ql><![CDATA[WHERE topicKey is not null]]></ejb-ql>
    </query>
    </entity>
    </enterprise-beans>
    <assembly-descriptor>
    <container-transaction>
    <method>
    <ejb-name>SurveyEJB</ejb-name>
    <method-intf>Remote</method-intf>
    <method-name>*</method-name>
    </method>
    <trans-attribute>Required</trans-attribute>
    </container-transaction>
    <container-transaction>
    <method>
    <ejb-name>TopicEJB</ejb-name>
    <method-intf>Remote</method-intf>
    <method-name>*</method-name>
    </method>
    <trans-attribute>Required</trans-attribute>
    </container-transaction>
    </assembly-descriptor>
    <dependents>
    <dependent>
    <description>Topic</description>
    <dependent-class>erm.com.clickaction.erm.surveys.ejb20.Topic</dependent-class>
    <dependent-name>Topic</dependent-name>
    <cmp-field><field-name>topicKey</field-name></cmp-field>
    <cmp-field><field-name>name</field-name></cmp-field>
    <cmp-field><field-name>description</field-name></cmp-field>
    <pk-field>topicKey</pk-field>
    </dependent>
    </dependents>
    <relationships>
    <ejb-relation>
    <ejb-relation-name>Survey-Topic</ejb-relation-name>
    <ejb-relationship-role>
    <ejb-relationship-role-name>survey-has-topics</ejb-relationship-role-name>
    <multiplicity>one</multiplicity>
    <role-source><ejb-name>SurveyEJB</ejb-name></role-source>
    <cmr-field>
    <cmr-field-name>topics</cmr-field-name>
    <cmr-field-type>java.util.Collection</cmr-field-type>
    </cmr-field>
    </ejb-relationship-role>
    <ejb-relationship-role>
    <ejb-relationship-role-name>topics-belongto-survey</ejb-relationship-role-name>
    <multiplicity>many</multiplicity>
    <cascade-delete/>
    <role-source><dependent-name>TopicEJB</dependent-name></role-source>
    <cmr-field>
    <cmr-field-name>survey</cmr-field-name>
    </cmr-field>
    </ejb-relationship-role>
    </ejb-relation>
    </relationships>
    </ejb-jar>
    thanks
    simon evans
    [email protected]

  • Cascade or delete in database server, why if my EJB do it for me??

    Hi,
    I am in design phase of a database for my j2EE application. In the database desing i have some relationships entities, that have foreign keys. I have several options about foreign keys in the relationships, cascade deletes, restrict .... all in my database server.
    But, when i am reading the referencial integrity of the entity EJBs CMP relationships, the entity beans make the cascade deletes automaticaly for maintain the relationsships.
    Need i make my relationships in my database server with cascade delete options or leave it for my application server???
    Another one, if i make relationships in my database server, why i need do it in my entity beans???
    tanks, sorry for my poor english

    Hi Markus,
    Tanks for your answer, if this tip only for entity beans with CMP???
    For example, if i have some entity beans, one with CMP and other with JDO, or for example, an entity beans that use CMP and JDO for access to few tables (i dont know that it is possible or it a good design), how can i design the relationships update/delete cascades in my database server, all entity beans persistence types support his referencial integrity ?? if this if true i think that i forget the relationships updates/deletes cascades in my database server.
    At this moment, i dont know what type of persistence i will use in my application server. I dont undertand yet wath approach i must follow, i design my database and after design my entity beans over this database or i must foget my database and beging with entity beans design first .... i have a big problem, i need read a lot of more.
    Something for help me???
    Very, very thanks

  • "is already defined" error

    Hi ppl
    I've been wrestling with this all afternoon.
    I'm getting deployment errors, for example, /usr/local/j2sdkee1.3.1/repository/localhost.localdomain/gnrtrTMP/myPlans3/SizeOptionBean_PM.java:73: setProductCode(ProductLocal) is already defined in SizeOptionBean_PM
    public void setProductCode(ProductLocal productCode) {
    Size option bean defines:
         // CMP relationship fields
         public abstract ProductLocal getProductCode();
         public abstract void setProductCode(String pProductCode);and in the deploytool productCode is listed, I've got it marked as persisting along with all the other fields, and there's a relationship set up between this and the product bean.
    The error suggests the field is being set up virtually by the deploytool and that I've done something superfluous that duplicates the field, but I can't see where.
    I do vaguely remember some situation where a field shouldn't be marked as persistent in the deploytool, but I've worked through all my notes and can't find it.
    Gizzaclue someone :-)
    Cheers
    J

         public abstract ProductLocal getProductCode();
    public abstract void setProductCode(String pProductCode);Shouldn't you be passing ProductLocal to the setProduct() method?

  • Basic ques - Local Interface

    Is it mandatory to have Local Interfaces in my ejbs built in EJB2.0? Or can I build
    my beans without them?

    As Rob stated you have to use local ejbs when you define a CMP2.0
    relationship (example Customer-Contact, where Contact is defined as a local
    ejb).
    Also, you could prefer to use local ejbs if you think they are going to be
    accessed from the same virtual machine.
    Do I have to have classes derived from EJBLocalObject and EJBLocalHome in my
    ejb?
    Yes. Your local ejb interface should extend EJBLocalObject and the home
    interface should extend EJBLocalHome.
    "vishal" <[email protected]> wrote in message
    news:3c764d48$[email protected]..
    >
    Do I have to have classes derived from EJBLocalObject and EJBLocalHome inmy ejb?
    >
    >
    Rob Woollen <[email protected]> wrote:
    The only requirement is that container-managed relationships are only
    through local
    interfaces. If you're not using EJB 2.0 CMP relationships, then you
    can continue to
    use remote interfaces if you wish.
    -- Rob
    vishal wrote:
    Is it mandatory to have Local Interfaces in my ejbs built in EJB2.0?Or can I build
    my beans without them?

  • Composite Primary Key in M:N CMP Entity Bean Relationship

    Dear Sir/Madam,
         We are creating an Enterprise Application for our institute using EJB 2.0 specifiactions. In the course of developement, we are facing a problem in writing the CMP Entity Beans with EJB Relationships.
         We are having many to many relationship between two beans such that the primary key of one Entity Bean (let's call it A), serves as the foreign key of another Entity Bean (let's call it B). Further, this primary key of A as foreign key in B, participates in the composite key of B.
         The EJB Specifications require that the primary key field(s) of any bean (B, in our case) declared in the Primary Key class should be the subset of the 'cmp-field' declared in the deployment descriptor for that bean. As I said earlier, we have many to many relationship at play. Hence, we require to keep the foerign key in the 'cmr-field' in lieu of 'cmp-field'. In short, the component of primary key is in 'cmr-field' while, it is needed in both 'cmp-field' and 'cmr-field'. That's perfect from Database point of view but illogical from CMP Entity Bean's view.
         How can we write the deployment descriptor for such a CMP (BMP is working fine for above scenario) Entity Bean? Also, how can we write the Primary Key class? The problem is not just to find the solution, but find under the hood of EJB 2.0 specifications.
         Please help.

    I think you should realise that it would not be convenient to use CMP for everything. It is difficult to define complex relations using CMP. Mostly BMP os preferd since it gives the flexibility for the bean developer.
    Regards
    xH4x0r

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

  • Could I build 1:N relationship between CMP and BMP?

    Hi, as subject, Could I build 1:N relationship between CMP and BMP?
    Thanks a lot!
    a13519

    Container managed relationships only apply to CMP beans. You can look at the DTD in appendix B of the EJB spec or chapter 10 where they make this distinction.

  • Weblogic-cmp-rdbms-jar.xml for One-To-Many unidirectional relationship

    hi,
    I am trying to create a simple cmp One-To-Many unidirectional relationship and deploy the same in weblogic. Can someone help me with the weblogic-cmp-rdbms-jar.xml. Am attaching the weblogic-cmp-rdbms-jar. xml tht i am using as also the corresponding ejb-jar.xml. Pls. note tht i want a unidirectional relationship here. one i am tryng However i get this error:
    Error while reading 'META-INF/weblogic-cmp-rdbms-jar.xml'. The error was: Role 'Supplier supplies Products' of relationship 'Product Supplier' contains an invalid key-column value of 'productID'. The key-column must specify a primary key column in the related bean. However, there is no primary key column named 'productID' defined in the related bean 'ProductEJB' or else 'productID' is not being recognized due to case mismatch. My weblogic-cmp-rdbms-jar
    <?xml version="1.0"?>
    <!DOCTYPE weblogic-rdbms-jar PUBLIC '-//BEA Systems, Inc.//DTD WebLogic 8.1.0 EJB RDBMS Persistence//EN' 'http://www.bea.com/servers/wls810/dtd/weblogic-rdbms-jar.dtd'>
    <weblogic-rdbms-jar>
    <weblogic-rdbms-bean>
         <ejb-name>SupplierEJB</ejb-name>
         <data-source-name>RJDataSource</data-source-name>
         <table-map>
               <table-name>AA_Supplier</table-name>
               <field-map>
                     <cmp-field>supplierID</cmp-field>
                     <dbms-column>supplierID</dbms-column>
               </field-map>
               <field-map>
                    <cmp-field>name</cmp-field>
                    <dbms-column>name</dbms-column>
               </field-map>
         </table-map>
    </weblogic-rdbms-bean>
    <weblogic-rdbms-bean>
           <ejb-name>ProductEJB</ejb-name>
           <data-source-name>RJDataSource</data-source-name>
           <table-map>
                 <table-name>AA_Product</table-name>
                 <field-map>
                      <cmp-field>productID</cmp-field>
                      <dbms-column>productid</dbms-column>
                 </field-map>
                 <field-map>
                      <cmp-field>description</cmp-field>
                      <dbms-column>description</dbms-column>
                 </field-map>
                 <field-map>
                      <cmp-field>basePrice</cmp-field>
                      <dbms-column>baseprice</dbms-column>
                 </field-map>
                <field-map>
                      <cmp-field>name</cmp-field>
                      <dbms-column>name</dbms-column>
                 </field-map>
                 <field-map>
                     <cmp-field>supplierID</cmp-field>
                       <dbms-column>supplierID</dbms-column>
                 </field-map>
            </table-map>
    </weblogic-rdbms-bean>
    <weblogic-rdbms-relation>
         <relation-name>Product Supplier</relation-name>
         <weblogic-relationship-role>
              <relationship-role-name>Supplier supplies Products</relationship-role-name>
              <relationship-role-map>
                   <column-map>
                        <foreign-key-column>supplierID</foreign-key-column>
                        <key-column>productID</key-column>
                   </column-map>
              </relationship-role-map>
         </weblogic-relationship-role>
         <weblogic-relationship-role>
              <relationship-role-name>Product supplied by Supplier</relationship-role-name>
              <relationship-role-map>
              <column-map>
                   <foreign-key-column>products</foreign-key-column>
                   <key-column>supplierID</key-column>
              </column-map>
              </relationship-role-map>
         </weblogic-relationship-role>
    </weblogic-rdbms-relation>
    </weblogic-rdbms-jar> My ejb-jar.xml
    <?xml version="1.0"?>
    <!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>
         <enterprise-beans>
         <entity>
              <ejb-name>SupplierEJB</ejb-name>
              <home>com.tpt.practice.entityBeans.cmp.product.relationship.SupplierHome</home>
              <remote>com.tpt.practice.entityBeans.cmp.product.relationship.Supplier</remote>
              <ejb-class>com.tpt.practice.entityBeans.cmp.product.relationship.SupplierEJB</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>AA_Supplier</abstract-schema-name>
              <cmp-field>
                   <field-name>supplierID</field-name>
              </cmp-field>
              <cmp-field>
                   <field-name>name</field-name>
              </cmp-field>
              <primkey-field>supplierID</primkey-field>
              <ejb-ref>
                        <ejb-ref-name>ProducEJB</ejb-ref-name>
                        <ejb-ref-type>Entity</ejb-ref-type>
                        <home>com.tpt.practice.entityBeans.cmp.product.ProductHome</home>
                        <remote>com.tpt.practice.entityBeans.cmp.product.Product</remote>
                        <ejb-link>ProductEJB#ProductEJB.jar</ejb-link>
              </ejb-ref>
              <query>
                   <query-method>
                        <method-name>findByName</method-name>
                        <method-params>
                             <method-param>java.lang.String</method-param>
                        </method-params>
                   </query-method>
                   <ejb-ql>
                        <![CDATA[SELECT OBJECT(a) FROM AA_Supplier AS a WHERE a.name =
                        ?1]]>
                   </ejb-ql>
              </query>
              <query>
                   <query-method>
                        <method-name>findAllSuppliers</method-name>
                        <method-params>
                        </method-params>
                   </query-method>
                   <ejb-ql>
                        <![CDATA[SELECT OBJECT(a) FROM AA_Supplier AS a WHERE a.supplierID
                        IS NOT NULL]]>
                   </ejb-ql>
              </query>
         </entity>
         <entity>
              <ejb-name>ProductEJB</ejb-name>
              <home>com.tpt.practice.entityBeans.cmp.product.relationship.ProductHome</home>
              <remote>com.tpt.practice.entityBeans.cmp.product.relationship.Product</remote>
              <local-home>com.tpt.practice.entityBeans.cmp.product.relationship.ProductLocalHome</local-home>
              <local>com.tpt.practice.entityBeans.cmp.product.relationship.ProductLocal</local>
              <ejb-class>com.tpt.practice.entityBeans.cmp.product.relationship.ProductEJB</ejb-class>
              <persistence-type>Container</persistence-type>
              <prim-key-class>com.tpt.practice.entityBeans.cmp.product.relationship.ProductPK</prim-key-class>
              <reentrant>False</reentrant>
              <cmp-version>2.x</cmp-version>
              <abstract-schema-name>AA_Product</abstract-schema-name>
              <cmp-field>
                   <field-name>productID</field-name>
              </cmp-field>
              <cmp-field>
                   <field-name>name</field-name>
              </cmp-field>
              <cmp-field>
                   <field-name>description</field-name>
              </cmp-field>
              <cmp-field>
                   <field-name>basePrice</field-name>
              </cmp-field>
              <cmp-field>
                   <field-name>supplierID</field-name>
              </cmp-field>
              <primkey-field>productID</primkey-field>
              <query>
                   <query-method>
                        <method-name>findByName</method-name>
                        <method-params>
                             <method-param>java.lang.String</method-param>
                        </method-params>
                   </query-method>
                   <ejb-ql>
                        <![CDATA[SELECT OBJECT(a) FROM AA_Product AS a WHERE a.name =
                        ?1]]>
                   </ejb-ql>
              </query>
              <query>
                   <query-method>
                        <method-name>findByDescription</method-name>
                        <method-params>
                             <method-param>java.lang.String</method-param>
                        </method-params>
                   </query-method>
                   <ejb-ql>
                        <![CDATA[SELECT OBJECT(a) FROM AA_Product AS a WHERE a.description
                        = ?1]]>
                   </ejb-ql>
              </query>
              <query>
                   <query-method>
                        <method-name>findByBasePrice</method-name>
                        <method-params>
                             <method-param>double</method-param>
                        </method-params>
                   </query-method>
                   <ejb-ql>
                        <![CDATA[SELECT OBJECT(a) FROM AA_Product AS a WHERE a.basePrice =
                        ?1]]>
                   </ejb-ql>
              </query>
              <query>
                   <query-method>
                        <method-name>findExpensiveProducts</method-name>
                        <method-params>
                             <method-param>double</method-param>
                        </method-params>
                   </query-method>
                   <ejb-ql>
                        <![CDATA[SELECT OBJECT(a) FROM AA_Product AS a WHERE a.basePrice >
                        ?1]]>
                   </ejb-ql>
              </query>
              <query>
                   <query-method>
                        <method-name>findCheapProducts</method-name>
                        <method-params>
                             <method-param>double</method-param>
                        </method-params>
                   </query-method>
                   <ejb-ql>
                        <![CDATA[SELECT OBJECT(a) FROM AA_Product AS a WHERE a.basePrice <
                        ?1]]>
                   </ejb-ql>
              </query>
              <query>
                   <query-method>
                        <method-name>findAllProducts</method-name>
                        <method-params>
                        </method-params>
                   </query-method>
                   <ejb-ql>
                        <![CDATA[SELECT OBJECT(a) FROM AA_Product AS a WHERE a.productID
                        IS NOT NULL]]>
                   </ejb-ql>
              </query>
         </entity>
         </enterprise-beans>
         <relationships>
         <ejb-relation>
              <ejb-relation-name>Product Supplier</ejb-relation-name>
              <ejb-relationship-role>
                   <ejb-relationship-role-name>Supplier supplies Products</ejb-relationship-role-name>
                   <multiplicity>One</multiplicity>
                   <relationship-role-source>
                        <ejb-name>SupplierEJB</ejb-name>
                   </relationship-role-source>
                   <cmr-field>
                        <cmr-field-name>products</cmr-field-name>
                        <cmr-field-type>java.util.Collection</cmr-field-type>
                   </cmr-field>
              </ejb-relationship-role>
              <ejb-relationship-role>
                   <ejb-relationship-role-name>Product supplied by Supplier</ejb-relationship-role-name>
                   <multiplicity>Many</multiplicity>
                   <relationship-role-source>
                        <ejb-name>ProductEJB</ejb-name>
                   </relationship-role-source>
              </ejb-relationship-role>
         </ejb-relation>
         </relationships>
         <assembly-descriptor>
              <container-transaction>
              <method>
                   <ejb-name>SupplierEJB</ejb-name>
                   <method-intf>Remote</method-intf>
                   <method-name>*</method-name>
              </method>
              <trans-attribute>Required</trans-attribute>
              </container-transaction>
         </assembly-descriptor>
    </ejb-jar>

    I think u r some confusion with productID and SuppliedID . primary key of one column( productId ) can be a foreign key of other table colum( SuppliedID). but foreign key( SuppliedID) can not be a primary key of second table .u declared SuppliedId as primary key . so ur mapping is incorrect.

  • Problem with cascade delete in CMP one-to-one relationship

    I am not able to cascade delete for one-to-one relationship. Even though relationship seems to be setup correctly, record from the second table is not deleted.
    Following is the structure of tables i am using:
    First Table(vcc_lrmc) -- LRMCBean
    lrmc_id pk (Bean field is id)
    lrmc_dtl_id (Bean field islrmcDtlId)
    Second Table (vcc_lrmc_dtl) -- LRMCDetailBean
    lrmc_dtl_id (pk) (Bean field islrmcDtlId)
    lrmc_id (Bean field id)
    One to one bidirectional relationship has been setup with CMR fields moreLRMC and mainLRMC.
    section of ejb-jar is as follows:
    <ejb-relation>
    <ejb-relation-name>LRMCMainToDetail</ejb-relation-name>
    <ejb-relationship-role>
    <multiplicity>One</multiplicity>
    <relationship-role-source>
    <ejb-name>LRMC</ejb-name>
    </relationship-role-source>
    <cmr-field>
    <cmr-field-name>moreLRMC</cmr-field-name>
    </cmr-field>
    </ejb-relationship-role>
    <ejb-relationship-role>
    <multiplicity>One</multiplicity>
    <cascade-delete/>
    <relationship-role-source>
    <ejb-name>LRMCDetail</ejb-name>
    </relationship-role-source>
    <cmr-field>
    <cmr-field-name>mainLRMC</cmr-field-name>
    </cmr-field>
    </ejb-relationship-role>
    </ejb-relation>
    section of orion-ejb-jar is as follows:(Bidirectional mapping)
    <entity-deployment name="LRMC" data-source="jdbc/VCCDS" table="VCC_LRMC">
    <cmp-field-mapping name="moreLRMC">
    <entity-ref home="LRMCDetail">
    <cmp-field-mapping name="lrmcDtlId" persistence-name="LRMC_DTL_ID"/>
    </entity-ref>
    </cmp-field-mapping>
    </entity-deployment>
    <entity-deployment name="LRMCDetail" data-source="jdbc/VCCDS" table="VCC_LRMC_DTL">
    <cmp-field-mapping name="mainLRMC">
    <entity-ref home="LRMC">
    <cmp-field-mapping name="id" persistence-name="LRMC_ID"/>
    </entity-ref>
    </cmp-field-mapping>
    </entity-deployment>
    Is there anything else need to be setup for Cascade delete or is there anything wrong the way one-to-one relationship has been setup.
    Pls. advice.
    Thanks
    Dhiraj

    Is it happening because of this bug.
    Cannot create a 1:1 bi-directional CMR for entity beans when database tables are reverse engineered. (2447364)
    Anyone, any idea on this ?
    Cheers,
    Dhiraj

Maybe you are looking for