What do you mean with "If data comes from bean's environment,"???
regards
Dapeng Wang
> -----Original Message-----
> From: Victor Langelo [SMTP:[EMAIL PROTECTED]]
> Sent: Monday, December 11, 2000 4:05 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Singelton Bean
>
> "Jeffery, Myles" wrote:
>
> > In number 2. how do you determine if the EJB already exists?
>
> Depends on how you are storing the data. If data comes from bean's
> environment,
> there is no need to create the entity, it always exists. I always throw an
> exception in this case.
>
> If it's stored in the database, use the same techniques you would with any
> other
> entity bean. Generally, I use a unique primary key index which causes an
> sql
> exception when trying to insert a duplicate.
>
> --Victor
>
> >
> >
> > > -----Original Message-----
> > > From: Victor Langelo [SMTP:[EMAIL PROTECTED]]
> > > Sent: 08 December 2000 17:33
> > > To: [EMAIL PROTECTED]
> > > Subject: Re: Singelton Bean
> > >
> > > Let me clarify my previous statement regarding singleton entity beans.
> > > This is
> > > definitely possible to do in a spec compliant way. I was only pointing
> out
> > > that
> > > you probably shouldn't assume that findByPrimaryKey will behave
> exactly
> > > like other
> > > finder methods.
> > >
> > > I have implemented singletons using BMP. Some access the database,
> others
> > > simply
> > > return "static" data defined in the bean's deployment descriptor. The
> > > pattern is
> > > roughly as follows:
> > >
> > > 1. There is only one primary key value for this entity.
> > > 2. ejbCreate should only allow one bean instance. If it already
> exists,
> > > throw
> > > CreateException.
> > > 3. ejbFindByPrimaryKey should return the primary key only when called
> with
> > > the
> > > single primary key value.
> > > 4. Create another finder, i.e. ejbFindTheInstance(), which returns the
> > > single
> > > primary key.
> > > 5. Either find the bean using the findTheInstance finder or using
> > > findByPrimaryKey
> > > with the single primary key value. I put the key in the home interface
> to
> > > make
> > > this easy.
> > >
> > > Hope this makes sense,
> > >
> > > Victor
> > >
>
> ==========================================================================
> =
> 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".