Re: Oracle Sequences and CMP

2001-02-18 Thread Alex 'Kazuma' Garbagnati


I'm trying to use CMP for beans that map to tables in which the primary key
is an integer that comes from an Oracle SEQUENCE.

How do I get the container to get the next number from the appropriate
SEQUENCE on a create?

You could build a Session Bean that will take care of connecting directly 
to the database and get the "next number" from the given sequence.

If you want, I'll suggest you to take a look to a very interesting thread 
present on www.theserverside.com, regarding a session bean generating 
unique values for PrimaryKeys. It's worth a read.


 Hope this helps...
 Best regards,
 Alex


Cos'e' il genio. E' fantasia intuizione, colpo d'occhio e velocita' 
d'esecuzione. (Amici Miei)

---
Alessandro A. 'Kazuma' Garbagnati
http://www.kazuma.net/   ICQ UIN: 1600386
Mountain View, CA, 94043 - USA





RE: Oracle Sequences and CMP

2001-02-18 Thread Mike Cannon-Brookes

Quite simply, you can't ;)

EJBs must generate their own primary keys. The only way you can do this is
have another bean that runs a custom SQL query to get a new ID from the
sequence and then use that. But this is very ugly, not DB independent and
involves coding SQL in your bean. I don't recommend it at all.

-mike

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED]]On Behalf Of Dan Cramer
 Sent: Sunday, February 18, 2001 5:59 PM
 To: Orion-Interest
 Subject: Oracle Sequences and CMP


 I'm trying to use CMP for beans that map to tables in which the
 primary key
 is an integer that comes from an Oracle SEQUENCE.

 How do I get the container to get the next number from the appropriate
 SEQUENCE on a create?

 Help is appreciated,
 Dan Cramer
 Chief Architect
 Dynamic Resolve, LLC
 Internet Solutions Consulting