As a BMP using oracle it is pretty easy.

We set up sequences for all our PK's. we call the sequence to get the next
one, and use that as a PK.

I guess you could do that in the Create(...) call but like our method it
would not be portable accross databases.

You could also do a SELECT  PKFIELD from PKTABLE order by PKFIELD;

and then just increment the last PK grabbed. It more intensive than the
sequence method in Oracle, but it is portable. Especially if you use a
Datasource resource, and do it that way.

Al

----- Original Message -----
From: "Enrique Wallace" <[EMAIL PROTECTED]>
To: "Orion-Interest" <[EMAIL PROTECTED]>
Sent: Sunday, July 23, 2000 6:07 PM
Subject: RE: EJB creation


> I tried to do this with MS Access, but by not specifying the id field, it
> defaults to 0 and after the first time, it reports a duplicate key error.
I
> tried -1 and null as well, but it accepts -1 as a key, and an int can't be
> set to null.  Is there a way to have the ejbCreate() method not try to
> assign any value to the primary key and let the DB autonumber handle it?
> Have you gotten an EJB to work with an autonumber field?  Thanks for any
> help.
>
> ekw
>
> >From: "J.T. Wenting" <[EMAIL PROTECTED]>
> >Reply-To: <[EMAIL PROTECTED]>
> >To: "'Enrique Wallace'" <[EMAIL PROTECTED]>,
> ><[EMAIL PROTECTED]>
> >Subject: RE: EJB creation
> >Date: Sun, 23 Jul 2000 00:53:24 +0200
> >
> >The only way to do that is to use database-specific datatypes like
> >autonumber fields. These are not part of the SQL standard, so you loose
> >portability.
> >
> >J.T. Wenting
> >http://www.hornet.demon.nl
> >
> >all spam sent to this account will be reported to proper authorities
> >
> >
> > > -----Original Message-----
> > > From: [EMAIL PROTECTED]
> > > [mailto:[EMAIL PROTECTED]]On Behalf Of Enrique
> > > Wallace
> > > Sent: Saturday, July 22, 2000 10:12 PM
> > > To: Orion-Interest
> > > Subject: EJB creation
> > >
> > >
> > > I've been learning EJB from Monson-Hefel's book and was
> > > pleased that i got
> > > the examples working and that i understood (most of) it.  I
> > > went on to try
> > > and create an EJB application of my own when I ran into a
> > > roadblock.  I
> > > realized in all the examples, when creating an entity bean,
> > > the app had to
> > > supply the primary key value.
> > >
> > > Is there a way to let the database take care of the primary key value
> > > creation?  I just want to create a new entity bean (and
> > > therefore a new
> > > record in the DB) without worrying about what its primary key
> > > should be.  i
> > > want to let the DB take care of that.  Can anyone help me
> > > with this?  is
> > > this process server specific or j2ee specified?  thanks for any help.
> > >
> > > ekw
> > >
> > > p.s. I must say this list has been very responsive to my
> > > questions.  other
> > > EJB servers i tried (jboss, for example) and where i have
> > > asked questions on
> > > their respective list have yielded almost nothing, probably
> > > because my
> > > questions are so newbie.  thanks!
> > >
> > > ______________________________________________________________
> > > __________
> > > Get Your Private, Free E-mail from MSN Hotmail at
> > > http://www.hotmail.com
> > >
> > >
> >
>
> ________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
>
>


Reply via email to