One solution that is database independent is to use Scott Ambler's High
Low solution.  In a nutshell:

- create a table named primary_keys(key_name varchar, next_value
number/varchar)
- populate the table with the names of your tables
- create a stateless session bean that gets the next_value from your
primary_keys table
- have your entity beans call your session bean to get their next key
value

If you do a search on google for Scott Ambler (www.ronin.com) you should
find the solution *somewhat* clearer.

Damon

On Thu, 2002-06-13 at 08:26, Javier A. Soltero wrote:
> Do you or anyone else on this list have any suggestions about handling 
> this problem effectively (and portably for different DBs) in 3.0?
> 
> Any suggestions would be appreciated. Currently, I'm guessing the only 
> way to accomplish this is to have a separate class which can look up the 
> next value in the sequence.
> 
> thanks.
> 
> -javier
> 
> Dain Sundstrom wrote:
> > That won't work with CMP.  It does work with BMP if you are going that 
> > route.  Unknown primary keys are are at the top of the new features 
> > list,  so it will be at least a month.
> > 
> > -dain
> > 
> > Arthur Wang wrote:
> > 
> >> I am using auto_increment function of MySql database for primary key of
> >> entity bean , so I don't need to set pk in ejbCreate, mysql will 
> >> populate pk
> >> field in the datatbase automatically, but it has following exceptions.
> >>
> >> -----Original Message-----
> >> From: Dain Sundstrom [mailto:[EMAIL PROTECTED]]
> >> Sent: Friday, June 07, 2002 4:35 PM
> >> To: [EMAIL PROTECTED]
> >> Subject: Re: [JBoss-user] Using auto increment of mysql for PK
> >>
> >>
> >> You need to be more specific. What exactly did you try?
> >>
> >> -dain
> >>
> >> Arthur Wang wrote:
> >>
> >>
> >>> Hi,
> >>> I tried to use auto_increment for primary key when I create a new entity
> >>> bean, but there are following exception:
> >>>
> >>> ---------------------
> >>> HTTP ERROR: 500 removing bean lock and it has tx set!; nested exception
> >>>
> >> is:
> >>
> >>> java.lang.IllegalStateException: removing bean lock and it has tx set!
> >>> Embedded Exception removing bean lock and it has tx set!; nested 
> >>> exception
> >>> is: java.lang.IllegalStateException: removing bean lock and it has tx
> >>>
> >> set!;
> >>
> >>> nested exception is: javax.ejb.TransactionRolledbackLocalException:
> >>>
> >> removing
> >>
> >>> bean lock and it has tx set!; nested exception is:
> >>> java.lang.IllegalStateException: removing bean lock and it has tx set!
> >>> Embedded Exception removing bean lock and it has tx set!; nested 
> >>> exception
> >>> is: java.lang.IllegalStateException: removing bean lock and it has tx 
> >>> set!
> >>> ----------------
> >>>
> >>> Any reply would be highly appreciated.
> >>> thanks
> >>>
> >>>
> >>> Arthur Wang
> >>> Ensemble Systems Inc.
> >>> Tel: (604)232-7954 Fax: (604)231-9545
> >>> www.ensemble-systems.com
> >>>
> >>>
> >>>
> >>> _______________________________________________________________
> >>>
> >>> Don't miss the 2002 Sprint PCS Application Developer's Conference
> >>> August 25-28 in Las Vegas -
> >>>
> >> http://devcon.sprintpcs.com/adp/index.cfm?source=osdntextlink
> >>
> >>> _______________________________________________
> >>> JBoss-user mailing list
> >>> [EMAIL PROTECTED]
> >>> https://lists.sourceforge.net/lists/listinfo/jboss-user
> >>>
> >>>
> >>
> >>
> >>
> >> _______________________________________________________________
> >>
> >> Don't miss the 2002 Sprint PCS Application Developer's Conference
> >> August 25-28 in Las Vegas -
> >> http://devcon.sprintpcs.com/adp/index.cfm?source=osdntextlink
> >>
> >> _______________________________________________
> >> JBoss-user mailing list
> >> [EMAIL PROTECTED]
> >> https://lists.sourceforge.net/lists/listinfo/jboss-user
> >>
> >> _______________________________________________________________
> >>
> >> Don't miss the 2002 Sprint PCS Application Developer's Conference
> >> August 25-28 in Las Vegas - 
> >> http://devcon.sprintpcs.com/adp/index.cfm?source=osdntextlink
> >>
> >> _______________________________________________
> >> JBoss-user mailing list
> >> [EMAIL PROTECTED]
> >> https://lists.sourceforge.net/lists/listinfo/jboss-user
> >>
> > 
> > 
> > 
> > _______________________________________________________________
> > 
> > Don't miss the 2002 Sprint PCS Application Developer's Conference
> > August 25-28 in Las Vegas - 
> > http://devcon.sprintpcs.com/adp/index.cfm?source=osdntextlink
> > 
> > _______________________________________________
> > JBoss-user mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/jboss-user
> > 
> 
> 
> 
> _______________________________________________________________
> 
> Don't miss the 2002 Sprint PCS Application Developer's Conference
> August 25-28 in Las Vegas - 
>http://devcon.sprintpcs.com/adp/index.cfm?source=osdntextlink
> 
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-user
-- 
Ranksix Solutions Inc.
[EMAIL PROTECTED]
250.514.6616

_______________________________________________________________

Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas - 
http://devcon.sprintpcs.com/adp/index.cfm?source=osdntextlink

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

Reply via email to