Try to take a look at the excellent EJB Design Patterns book by Floyd Marinescu at TheServerSide.com: http://www.theserverside.com/books/EJBDesignPatterns/index.jsp There's a whole chapter [chapter 5] about primary key generation strategies, maybe it might help you.
HTH Martin > -----Original Message----- > From: Dimitri PISSARENKO [mailto:[EMAIL PROTECTED]] > Sent: Monday, July 22, 2002 7:56 PM > To: [EMAIL PROTECTED] > Subject: [JBoss-user] Generating primary keys in mySQL > > > Hello! > > I have a table in a mySQL database which I access through JBoss 3.0.0 > (by means of CMP entity beans). > > In this table I have an integer primary key. When creating a new > record in the table, I have to generate a new primary key with the > query > > SELECT MAX(projectPrimaryKey)+1 FROM projects > > This query is executed by a session bean which manages the CMP entity > bean associated with the projects table. > > Is it somehow possible to let JBoss do this query or implement it in > a database-independent manner? That is, that I have absolutely no SQL > statements in my source code. > > Is it perhaps possible to put the code in some configuration file of > the bean? > > Thanks > > Dimitri Pissarenko > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > JBoss-user mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/jboss-user > ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ JBoss-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-user