Problems creating an entity with CMR that are PK - Weblogic

This is a discussion on Problems creating an entity with CMR that are PK - Weblogic ; There was another person asking the same question before but the answer he got doesn't work. If I have a CMR that is also primary key of the entity it cannot be created. I am using WLS 8.1 and have ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Problems creating an entity with CMR that are PK

  1. Problems creating an entity with CMR that are PK


    There was another person asking the same question before but the answer he got
    doesn't work.
    If I have a CMR that is also primary key of the entity it cannot be created.

    I am using WLS 8.1 and have three entity beans A, B and C where A has a single
    PK, B has A's pk + its own identifier as its pk and C which has B's pk + its own.
    The entities also has CMR to each others. When I try to create a C entity I get
    the follow errors using the two methods.

    Setting CMR
    [EJB:010146]The setXXX method for a cmr-field that is mapped to a primary key
    may not be called. The cmr-field is read-only.

    Setting CMP field
    [EJB:010145]When a cmp-field and a cmr-field (relationship) are mapped to the
    same column, the setXXX method for the cmp-field may not be called. The cmp-field
    is read-only.

    My conclusion is that this kind of entity can never be created using ejb calls.
    I have to create it using JDBC.

    /Björn

  2. Re: Problems creating an entity with CMR that are PK

    I too have faced this problem.
    The decision is simple.
    For example, in bean B you must have field a with A data type and setter+getter for it.

    In ejbCreate (or ejbPostCreate) write
    setA( A.findByPrimaryKey(A.PK value) );
    You can not use setXXX for field with CMR key value. Assign bean, not PK value!


    Andrey

    Björn Caroll wrote:
    > There was another person asking the same question before but the answer he got
    > doesn't work.
    > If I have a CMR that is also primary key of the entity it cannot be created.
    >
    > I am using WLS 8.1 and have three entity beans A, B and C where A has a single
    > PK, B has A's pk + its own identifier as its pk and C which has B's pk + its own.
    > The entities also has CMR to each others. When I try to create a C entity I get
    > the follow errors using the two methods.
    >
    > Setting CMR
    > [EJB:010146]The setXXX method for a cmr-field that is mapped to a primary key
    > may not be called. The cmr-field is read-only.
    >
    > Setting CMP field
    > [EJB:010145]When a cmp-field and a cmr-field (relationship) are mapped to the
    > same column, the setXXX method for the cmp-field may not be called. The cmp-field
    > is read-only.
    >
    > My conclusion is that this kind of entity can never be created using ejb calls.
    > I have to create it using JDBC.
    >
    > /Björn



  3. Re: Problems creating an entity with CMR that are PK

    You should be able to set the primary key fields of C during ejbCreate.
    This will
    establish the relationship between C and B. If this isn't working, it's a
    bug.

    Seth

    "Björn Caroll" wrote in message
    news:4046fe32@newsgroups.bea.com...
    >
    > There was another person asking the same question before but the answer he

    got
    > doesn't work.
    > If I have a CMR that is also primary key of the entity it cannot be

    created.
    >
    > I am using WLS 8.1 and have three entity beans A, B and C where A has a

    single
    > PK, B has A's pk + its own identifier as its pk and C which has B's pk +

    its own.
    > The entities also has CMR to each others. When I try to create a C entity

    I get
    > the follow errors using the two methods.
    >
    > Setting CMR
    > [EJB:010146]The setXXX method for a cmr-field that is mapped to a primary

    key
    > may not be called. The cmr-field is read-only.
    >
    > Setting CMP field
    > [EJB:010145]When a cmp-field and a cmr-field (relationship) are mapped to

    the
    > same column, the setXXX method for the cmp-field may not be called. The

    cmp-field
    > is read-only.
    >
    > My conclusion is that this kind of entity can never be created using ejb

    calls.
    > I have to create it using JDBC.
    >
    > /Björn




+ Reply to Thread