Hey all,

According to the EJB 1.1 spec (p. 131):

With bean-managed persistence, the entity Bean Provider is responsible for writing
the code that inserts a record into the database in the ejbCreate(...) methods.
However, with container-managed per-sistence, the container performs the database
insert after the ejbCreate(...) method completes.... The entity Bean Provider s
responsibility is to initialize the container-managed fields in the ejbCre-ate(...)
methods from the input arguments such that when an ejbCreate(...) method returns,
the container can extract the container-managed fields from the instance and insert
them into the data-base. The ejbCreate(...) methods must be defined to return the
primary key class type. The implemen-tation of the ejbCreate(...) methods should be
coded to return a null. The returned value is ignored by the Container.

So in the case of Container managed EJBs, you MUST return null.  In the case of
BMP, like the TestBean Entity Bean, you return the PK object for the newly created
EJB.

=Dan

"Mattias V. Bertelsen" wrote:

> Sebastien Alborini wrote:
> >
> > Peter Shillan wrote:
> > >
> > > Hi All,
> > >
> > > I downloaded Ken's jBoss stuff for the R M-H examples. I built everything,
> > > but got a client error so made the simplest client I could make, just to
> > > create a bean. I got the same error. I try to create a cabin bean, and I get
> > > the following, server-side and client-side respectively. jBoss looks OK, but
> > > the client is not!
> > >
> > > I have CVS from about 4hrs ago, so I should be current(-ish!!).
> > >
> > > Peter.
> > >
> >
> > Hi!
> >
> > I tried it, and ended up with the same result. This comes from
> > com.titan.cabin.CabinBean.ejbCreate():
> >
> >     public CabinPK ejbCreate(int id){
> >         this.id = id;
> >         return null;
> >     }
> >
> > The return type is the type of the bean's primary key (CabinPK, which
> > only contains an int), but the method returns null.  Is this legal?  (In
> > testbeans for example, the ejbCreate method for EntityPKBean returns the
> > bean's PK.)
> >
> > Sebastien
> >
>
> That seems pretty bogus to me.  It should definitely not return null.
> Also, I thought the whole point of the ejbcreate method was to verify if
> the entity by that key actually exists in the database?  All of my beans
> 'select id where id=?' and verify there is a result set.
>
> Mattias
>
> --
> --------------------------------------------------------------
> To subscribe:        [EMAIL PROTECTED]
> To unsubscribe:      [EMAIL PROTECTED]
> Problems?:           [EMAIL PROTECTED]

--
Daniel G. Koulomzin
Digital Media On Demand
244 Brighton Ave. 3rd Floor
Allston MA 02134





--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Problems?:           [EMAIL PROTECTED]

Reply via email to