This way of generating auto increment keys doesn't work without table
locks. There are many discussions of how to generate keys, I suggest you
find one and use a more reliable method.

david jencks

On 2002.03.05 18:00:43 -0500 Christine wrote:
> Hi, The reason I have this issue is because I am actually implementing
> the
> auto_increment by myself. The whole store is:
> I have a table with an integer type unique ID. everytime, when I create a
> new
> EJB object, I call the finderMaxID method to get the MAX ID, then MAX ID
> + 1 to
> get the new max id and create a new EJB object. at the same time, insert
> a new
> record to the table. In the whereclause for the finderMaxID, i used "
> WHERE ID
> IN (SELECT MAX(ID) FROM Customer)". Now, MySQL doesn't support
> sub-select. I
> have to use other way to do so.
> I am not sure whether I understood what you mean, but how can ORDER BY ID
> help?
> 
> Burkhard Vogel wrote:
> 
> > Hi,
> > if you are in one table and you have only one line which will be MAX,
> you
> > could use ORDER BY ID desc . Which will be much faster as well, if in
> two
> > tables, join them and do the same... But if there are more than one
> value...
> > Wait for MySQL 4.0 which will support subqueries.
> > Regards
> > Burkhard
> > ----- Original Message -----
> > From: "Christine" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Friday, March 01, 2002 1:12 PM
> > Subject: [JBoss-user] Finder Method in JBoss
> >
> > > Hi,
> > >
> > > I have a finder method which use sub-select as following:
> > > findMaxIDWhereClause : ID IN (SELECT MAX(ID) FROM Customer)
> > > it works fine when I used IBM WebSphere and DB2. Now I am switching
> to
> > > JBoss + Tomcat + MySQL. Cause MySQL doesn't support sub-select. Does
> > > anyone know whether there is some other way to get my
> > > findMaxIDWhereClause work without have to change code? Thanks in
> > > advance!
> > >
> > > regards,
> > > --
> > > Jia (Christine) Li
> > >
> > > 524N ICT Building
> > > Department of Computer Science
> > > University of Calgary
> > >
> > >
> > >
> > > _______________________________________________
> > > JBoss-user mailing list
> > > [EMAIL PROTECTED]
> > > https://lists.sourceforge.net/lists/listinfo/jboss-user
> 
> --
> Jia (Christine) Li
> 
> 524N ICT Building
> Department of Computer Science
> University of Calgary
> 
> 
> 
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-user
> 
> 

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

Reply via email to