It looks like the code is in this distribution:
ftp://ftp.exolab.org/pub/castor/castor_0.9.2/castor-0.9.2-src.zip
from this page http://castor.exolab.org/download.html

Look for *KeyGen*.java. I haven't had a chance to try to use it and I don't
know if you can use it with CMP entity beans.

Hal

> -----Original Message-----
> From: Jim Archer [mailto:[EMAIL PROTECTED]]
> Sent: Monday, May 07, 2001 3:30 AM
> To: [EMAIL PROTECTED]
> Subject: RE: [JBoss-user] EJB question
>
>
> Hal, were you able to find the actual source for this? I searched and
> searched last week with no luck...
>
> Jim
>
> --On Friday, May 04, 2001 8:33 AM -0400 "Deadman, Hal"
> <[EMAIL PROTECTED]> wrote:
>
> > Take a look at the key generator that comes with Exolab's Castor
> > (open-source). http://castor.exolab.org/key-generator.html
> >
> > You probably want something like their HIGH/LOW generator.
> I haven't used
> > it but I use a similiar technique that I wrote myself. I like their
> > implementation better because they let you use different key gen
> > techniques that you can specify in the config file without
> changing code.
> > They offer a max+1 option which you should stay away from
> b/c I don't see
> > how that could guarantee uniqueness.
> >
> > The castor high/low generator uses a database but it grabs
> a range of
> > values with each db hit so you don't hit the db everytime.
> >
> > Hal
> >
> >> -----Original Message-----
> >> From: Ralph Jensen [mailto:[EMAIL PROTECTED]]
> >> Sent: Friday, May 04, 2001 7:27 AM
> >> To: [EMAIL PROTECTED]
> >> Subject: Re: [JBoss-user] EJB question
> >>
> >>
> >> Thanks. But that is actually much more than I want. I only
> >> need a unique
> >> INT for primary keys.
> >>
> >> For the moment I will try this:
> >>
> >> In the sql-script:
> >>
> >> create table uniqueInteger(
> >>     pk INTEGER constraint pk_unique primary key,
> >>     uniqueID INTEGER
> >> );
> >>
> >> insert into uniqueInteger VALUES( 1, 1 );
> >>
> >>
> >> Then in the bean:
> >> SELECT uniqueID from uniqeInteger;
> >>
> >> save uniqueID in variable ( let's call it 'uniqueVar' )
> >>
> >> then:
> >>
> >> UPDATE uniqueInteger SET uniqueID = uniqueVar+1 WHERE pk = 1;
> >>
> >>
> >> I think that's basically Vinay's suggestion. Does that look
> >> reasonable?
> >> That's a lot of database access to get a unique primary key,
> >> just to be
> >> able to return it from ejbCreate() - especially in light of
> >> the fact, that
> >> databases do it automatically, if the table is created
> >> accordingly. Isn't
> >> this kind of thing done regularly?
> >>
> >>
> >> I know this has nothing to do with jBoss. Thank you.  :-)
> >>
> >> Ralph
> >>
> >> ----- Original Message -----
> >> From: Jim Downing <[EMAIL PROTECTED]>
> >> To: <[EMAIL PROTECTED]>
> >> Sent: Friday, May 04, 2001 5:47 PM
> >> Subject: Re: [JBoss-user] EJB question
> >>
> >>
> >> > Check out www.activescript.co.uk for a non-free ($99)
> component to
> >> generate
> >> > unique ids. The author has also posted the pattern on
> >> theserverside.com,
> >> so
> >> > you have something to work to if you want to implement
> it yourself.
> >> >
> >> > jim
> >> >
> >> > ----- Original Message -----
> >> > From: "Ralph Jensen" <[EMAIL PROTECTED]>
> >> > To: <[EMAIL PROTECTED]>
> >> > Sent: Friday, May 04, 2001 10:25 AM
> >> > Subject: Re: [JBoss-user] EJB question
> >> >
> >> >
> >> > > The portability would be there in terms of data access.
> >> How to tell the
> >> > > database to autoincrement when I create a table is
> probably always
> >> > database
> >> > > specific. Or not?
> >> > >
> >> > > I'm not good at SQL. So how would your suggestion look in
> >> code? What
> >> would
> >> > > the key generator bean look like? Off which table
> would it work?
> >> > >
> >> > > Ralph
> >> > >
> >> > > ----- Original Message -----
> >> > > From: Vinay Menon <[EMAIL PROTECTED]>
> >> > > To: JBOSS <[EMAIL PROTECTED]>
> >> > > Sent: Friday, May 04, 2001 4:29 PM
> >> > > Subject: Re: [JBoss-user] EJB question
> >> > >
> >> > >
> >> > > Why don't you just use a primary key generator bean to
> >> encapsulate the
> >> key
> >> > > genaration? The ejbCreate can then work off that ejb and
> >> assign the
> >> > primary
> >> > > key field to the primary key generated field? so your
> >> autoincrement
> >> > > essentially will not be on the same table as the ejb but
> >> a different
> >> one
> >> > > and the primary key generator will work off that table.
> >> [Also makes
> >> sure
> >> > > that you have complete protability in terms of the
> >> database server!]
> >> > >
> >> > > Vinay
> >> > >
> >> > >
> >> > >
> >> > > ----- Original Message -----
> >> > > From: Ralph Jensen
> >> > > Sent: Friday, May 04, 2001 8:52 AM
> >> > > To: [EMAIL PROTECTED]
> >> > > Subject: [JBoss-user] EJB question
> >> > >
> >> > >
> >> > > I asked this question elsewhere, but didn't get an answer. So:
> >> > >
> >> > > An entity bean's ejbCreate(...) method MUST return the
> >> primary key.
> >> That
> >> > is
> >> > > not a problem, if I specify the primary key myself and
> >> pass it to the
> >> > > create(...) method.
> >> > >
> >> > > But I want to let the database assign the primary key by
> >> creating a
> >> table
> >> > > with an AUTOINCREMENT default for the primary key column,
> >> like in this
> >> > > example using Cloudscape (part of SUN's J2EE v1.3):
> >> > >
> >> > > create table myTable(
> >> > >    id INT DEFAULT AUTOINCREMENT CONSTRAINT pk_id PRIMARY KEY,
> >> > >    someString VARCHAR(6),
> >> > >    etc.
> >> > > );
> >> > >
> >> > > Then I can use INSERT like this:
> >> > >    INSERT INTO mytable ( someString ) VALUES ( 'Hello' );
> >> > >
> >> > > The database then assigns a unique value to the id column
> >> of that new
> >> > > record.
> >> > >
> >> > > If I do this in the ejbCreate(...) method of my bean my
> >> problem is: How
> >> do
> >> > > I know that value in order to return it? Is that possible?
> >> > >
> >> > > Thanks
> >> > >
> >> > > Ralph Jensen
> >> > >
> >> > >
> >> > > _______________________________________________
> >> > > JBoss-user mailing list
> >> > > [EMAIL PROTECTED]
> >> > > http://lists.sourceforge.net/lists/listinfo/jboss-user<br
> >> > clear=all><hr>Get
> >> > > your FREE download of MSN Explorer at <a
> >> > >
> href="http://explorer.msn.com";>http://explorer.msn.com</a><br></p>
> >> > >
> >> > >
> >> > >
> >> > > _______________________________________________
> >> > > JBoss-user mailing list
> >> > > [EMAIL PROTECTED]
> >> > > http://lists.sourceforge.net/lists/listinfo/jboss-user
> >> > >
> >> > >
> >> >
> >> >
> >> > _______________________________________________
> >> > JBoss-user mailing list
> >> > [EMAIL PROTECTED]
> >> > http://lists.sourceforge.net/lists/listinfo/jboss-user
> >>
> >>
> >> _______________________________________________
> >> JBoss-user mailing list
> >> [EMAIL PROTECTED]
> >> http://lists.sourceforge.net/lists/listinfo/jboss-user
> >>
> >
> > _______________________________________________
> > JBoss-user mailing list
> > [EMAIL PROTECTED]
> > http://lists.sourceforge.net/lists/listinfo/jboss-user
>
>
>
> ********************************************
> I shall be telling this with a sigh
> Somewhere ages and ages hence:
> Two roads diverged in a wood, and I -
> I took the one less traveled by,
> And that has made all the difference.
>
> - Robert Frost, 1916
>
>
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/jboss-user
>

_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to