I'm sure there is a pattern similar to this on http://theserverside.com so
you should look there under its patterns page for primary key generation.

Peter.

----- Original Message -----
From: "Rickard Oberg" <[EMAIL PROTECTED]>
To: "jBoss" <[EMAIL PROTECTED]>
Sent: Thursday, September 28, 2000 3:48 AM
Subject: Re: [jBoss-User] container generated primary key for CMP EntityEJB


> >  > Is there any way to make a CMP entity EJB use a automatic value as
its
> >  > primary key, so that in the create method you dont have to pass it
the
> >  > primary key value ?
> >  >
> >  > If anyone has any idea I would really appreciate !
> >
> > Hmmm. The closest I've come to this is to write an MBean which
> > generates keys from sequences in a database. Then in ejbCreate you
> > connect to the MBean and get a new PK from it...
>
> How about this:
> One CMP bean with primary key being the bean name and an additional field
> currentId. It has a method nextId(int batchSize) which returns currentId
and
> also adds batchSize to currentId. This can then be called by a stateless
> session bean that has a method nextId(String beanName), which calls the
CMP
> bean to get the next id. It stores the next id from the CMP bean, and can
> then internally increment this counter batchSize times.
>
> Anyone has any objections? Would be pure EJB, and fast (only hits DB for
> every batchSize key generation request).
>
> /Rickard
>
>
>
>
> --
> --------------------------------------------------------------
> To subscribe:        [EMAIL PROTECTED]
> To unsubscribe:      [EMAIL PROTECTED]
> Problems?:           [EMAIL PROTECTED]
>



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

Reply via email to