• Post Reply Bookmark Topic Watch Topic
  • New Topic

CMP and sequence in oracle

 
william kane
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do i handle the following situation?
I have a CMP bean whose create method takes 4 paramters.These fields are inserted into the database by the container after I deploy the bean.But i also have a field in my oracle database table(primary key) that is sequence.
Oracle doesnot autogenerate sequences and i cannot insert code into a CMP.How do i go about it?How do i tell the container that my PK is a sequence that has to be generated before insertion?
Any pointers for the same will also do.
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pasted from Oracle 9ias ejb doc
Defining an Auto-Generated Primary Key
If you specify a java.lang.Object as the primary key class type in <prim-key-class>, but do not specify the primary key name in <primkey-field>, then the primary key is auto-generated by the container.
The employee example defines its primary key as a java.lang.Object. Thus, the container auto-generates the primary key.

Once defined, the container creates a column called autoid in the entity bean table for the primary key of type LONG. The container uses random numbers for the primary key values.
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The doc is for Oracle 9ias 9.0.3
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!