This was great, thanks for the reference. I've been reading some of the other chapters too. A question & suggestion on the Primary Key chapter: 1. Why is the current-time in ms part of the UUID? Since the random string at the end is based off the current time, wouldn't that be enough to ensure "down to" and "within an object" within a ms? I don't doubt there's good reason for it (maybe for substringing and comparing the times?) that I'm overlooking. But it could certainly shorten the id string to leave it off. Just curious -- is it just length that's part of what ensures uniqueness? Maybe I should read that UUI and GUID ref in the footnote. 2. http://www.cryptix.org/products/jce/index.html has a clean room impl of JCE that can be exported internationally, and supposedly has a faster implementation of the SecureRandom class (found this in today's ITWorld news letter on Java Security by Todd Sundsted). It might make a worthwhile footnote to the example in the UUID in EJB section. Best, Scott Stirling JRun QA Macromedia > -----Original Message----- > From: Floyd Marinescu [mailto:[EMAIL PROTECTED]] > Sent: Monday, August 27, 2001 9:37 PM > To: [EMAIL PROTECTED] > Subject: Re: [EJB-INT] Primary Key Generation - chapter posted on > TheServerSide.com > > > Hey guys, > > I have posted a chapter on Primary Key Generation > Strategies as part of the > EJB Design Patterns book project on TheServerSide.com. > > One of the strategies covered is the use of stored > procedures as you guys > have recently been discussing. The other patterns covered > provide beautiful > alternatives. You can download it here: > > http://www.theserverside.com/resources/patterns_review.jsp > > take care, > > Floyd Marinescu > > -----Original Message----- > From: A mailing list for Enterprise JavaBeans development > [mailto:[EMAIL PROTECTED]]On Behalf Of Dennis Djenfer > Sent: Sunday, August 26, 2001 7:05 AM > To: [EMAIL PROTECTED] > Subject: Re: Primary Key Generation > > > Thank you! > > This was exactly what I was looking for. I had overlooked that the > CallableStatement > actually implements the PreparedStatement interface. > > There are many discussion threads about how to generate > primary keys for > ejb's, but most > of the solutions run into problem when it comes to clusted application > servers, because > they ultimately needs the database to synchronize the > generation of keys. I > feel that > the solution below, where the database generates and returns > the primary key > in one call > is a very effecient solutions that also solves the clustering > problem. Any > comments on > that topic? > > > Again, thank you for the code example > > > // Dennis > > > Steve Muench wrote: > > > | > INSERT INTO yourtable(pk,y,z) > > | > VALUES(yoursequence.nextval,?,?) > > | > RETURNING pk INTO ? > > > > Dennis Djenfer wrote: > > > > | The SQL statement looks fine to me, but I don't know how > to execute this > statement > > | from JDBC. > > > > Here's an example program. > > > > import java.sql.Connection; > > import java.sql.Types; > > import java.sql.SQLException; > > import java.sql.CallableStatement; > > import java.sql.DriverManager; > > public class Example { > > private static final String STMT = "BEGIN INSERT INTO > DEPT(deptno,dname,loc) "+ > > > "VALUES(mydeptseq.nextval,?,?) "+ > > "RETURNING deptno INTO > ?; END;"; > > public static void main(String[] args) { > > Connection c = null; > > try { > > Class.forName("oracle.jdbc.driver.OracleDriver"); > > c = > DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:ORCL", > > "scott","tiger"); > > CallableStatement s = c.prepareCall(STMT); > > s.setString(1,"Example"); > > s.setString(2,"Sample"); > > s.registerOutParameter(3,Types.INTEGER); > > s.execute(); > > int i = s.getInt(3); > > System.out.println("Row inserted was assigned > sequence number "+i); > > } > > catch(Throwable t) { > > t.printStackTrace(System.err); > > } > > finally { > > if (c!=null) try { c.close(); } catch(SQLException ignore){} > > } > > } > > } > > > > > _____________________________________________________________________ > > Steve Muench - Developer, Product Manager, XML Evangelist, Author > > "Building Oracle XML Applications" - www.oreilly.com/catalog/orxmlapp > =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff EJB-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help". =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff EJB-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help". =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff EJB-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".
