If you create your bean, and the instance is deactivated, then you call
a business method and the container selects another instance from the
instance pool the primary key will not be valid unless you re-set it
in ejbActivate (or in ejbLoad but doing it in ejbActivate might be
a little more efficient).

Guess wrote:
>
> I guess I'm not understanding something. Isn't the primary key saved in
> the my_primary_key variable below when the ejbCreate is called?
> public class myEJB implements EntityBean {
>     public String my_primary_key;
>     public myEJBPK ejbCreate(String p_primary_key) { my_primary_key = p_primary_key; 
>}
>     // ... more code
> }
> Then why do we have to use
> public void ejbLoad() {
>      myEJBPK primaryKey = (myEJBPK) ctx.getPrimaryKey();
>      // .. more jdbc code
>      statement.setString(1, primaryKey.get_my_primary_key());
> }
> intead of just doing:
> statement.setString(1, my_primary_key); ?
> is it necessary to go through the getPrimaryKey() method of the EntityClass (ctx) ?
>
> ----- Original Message -----
> From: "Evan Ireland" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Monday, June 25, 2001 11:59 PM
> Subject: Re: necessary to get primary key from entitycontext?
>
> > The two places you can best save the key are ejbPostCreate and ejbActivate.
> >
> > Guess wrote:
> > >
> > > hello,
> > >
> > > i'm writing a BMP ejb. I'm wondering if it's necessary to get
> > > the primary key from the EntityContext through the getPrimaryKey()
> > > method. Can't I just use the cached primary key in ebjload?
> > >
> > > ===========================================================================
> > > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> > > of the message "signoff EJB-INTEREST".  For general help, send email to
> > > [EMAIL PROTECTED] and include in the body of the message "help".
> >
> > --
> > ________________________________________________________________________________
> >
> > Evan Ireland              Sybase EAServer Engineering        [EMAIL PROTECTED]
> >                             Wellington, New Zealand               +64 4 934-5856
> >
> > ===========================================================================
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> > of the message "signoff EJB-INTEREST".  For general help, send email to
> > [EMAIL PROTECTED] and include in the body of the message "help".
> >
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff EJB-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".

--
________________________________________________________________________________

Evan Ireland              Sybase EAServer Engineering        [EMAIL PROTECTED]
                            Wellington, New Zealand               +64 4 934-5856

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to