• Post Reply Bookmark Topic Watch Topic
  • New Topic

Sequence number in oracle using Entity Bean

 
Amar, Nandigam
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
This is my problem. We have a table in oracle database whose primary key is a sequence number. The primary key sequence number is maintained using a trigger on insert. Now I have an Entity Bean for this table. In my create method I am trying to populate the data other than primary key thinking that primary key field will be automatically filled by the trigger. But even before the request is going to weblogic server, I am getting the following error when I am running my test program calling create on my Home Interface weblogic 6.0 with ejb20.jar and the entity bean is following EJB2.0 specs). Any help in this regard is appreciated. If there is another way of creating Sequence and doing it let me know. Thanks in advance.
[java] weblogic.ejb20.RuntimeCheckerException: Your BMP ejbCreate should not be returning null.
[java] at weblogic.rmi.internal.AbstractOutboundRequest.sendReceive(Abs
tractOutboundRequest.java:90)
[java] at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwar
eRemoteRef.java:247)
[java] at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwar
eRemoteRef.java:225)
[java] at com.reliant.sparc.products.model.LotBeanHomeImpl_WLStub.creat
e(LotBeanHomeImpl_WLStub.java:132)
[java] at com.reliant.coresvcs.util.ResourceLocator.main(ResourceLocato
r.java:222)
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As the error message says you have to return the primary key from ejbCreate. If really want the trigger to generate your primary key, you could insert your data, read the generated primary key value from the inserted database record, and return that - although that will only work reliably if there's a suitable alternative primary key in your table with which you can find the inserted record.
Or, more efficiently, you might be able to use Oracle's INSERT INTO... RETURNING syntax, although I'm not entirely sure how you'd capture the returned value using JDBC.
(For those of you using SQL Server and identity columns having similar issues, you can do your insert followed by a SELECT @@IDENTITY).
- Peter

[This message has been edited by Peter den Haan (edited May 16, 2001).]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!