Creating Compound Primary Key in EJB

Hi there,
I'm creating a CMP EJB and am trying to use the Compund Primary Key option but I get the following error trace:
[EXCEPTION]
com.sap.engine.services.ejb.exceptions.BaseTransactionRolledbackLocalException: Exception in method com.nexeninc.seismic.ejb.SeisSetLocalHomeImpl0.create(java.lang.String,java.lang.String).
     at com.nexeninc.seismic.ejb.SeisSetLocalHomeImpl0.create(SeisSetLocalHomeImpl0.java:363)
     at com.nexeninc.seismic.ejb.SeismicServicesBean.registerDataSet(SeismicServicesBean.java:253)
     at com.nexeninc.seismic.ejb.SeismicServicesLocalLocalObjectImpl0.registerDataSet(SeismicServicesLocalLocalObjectImpl0.java:775)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:324)
     at com.sap.engine.services.webservices.runtime.EJBImplementationContainer.invokeMethod(EJBImplementationContainer.java:126)
     at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:157)
     at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:79)
     at com.sap.engine.services.webservices.runtime.servlet.ServletDispatcherImpl.doPost(ServletDispatcherImpl.java:92)
     at SoapServlet.doPost(SoapServlet.java:51)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
     at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
     at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
     at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
     at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
     at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
     at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
     at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
     at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
     at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
     at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
     at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
     at java.security.AccessController.doPrivileged(Native Method)
     at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
     at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
Caused by: com.sap.engine.services.applocking.exception.SAPAppLockingIllegalArgumentException: Inconsistency in number of primary keys
     at com.sap.engine.services.applocking.TableLockingImpl.getArgument(TableLockingImpl.java:388)
     at com.sap.engine.services.applocking.TableLockingImpl.lock(TableLockingImpl.java:129)
     at com.sap.engine.services.applocking.TableLockingImpl.lock(TableLockingImpl.java:139)
     at com.sap.engine.services.ejb.entity.pm.lock.TableLockingSystem.write(TableLockingSystem.java:82)
     at com.sap.engine.services.ejb.entity.pm.UpdatablePersistent.create(UpdatablePersistent.java:242)
     at com.nexeninc.seismic.ejb.SeisSetBean0Persistent.create(SeisSetBean0Persistent.java:703)
     at com.nexeninc.seismic.ejb.SeisSetBean0PM.ejbCreate(SeisSetBean0PM.java:370)
     at com.nexeninc.seismic.ejb.SeisSetLocalHomeImpl0.create(SeisSetLocalHomeImpl0.java:334)
     ... 27 more
com.sap.engine.services.applocking.exception.SAPAppLockingIllegalArgumentException: Inconsistency in number of primary keys
     at com.sap.engine.services.applocking.TableLockingImpl.getArgument(TableLockingImpl.java:388)
     at com.sap.engine.services.applocking.TableLockingImpl.lock(TableLockingImpl.java:129)
     at com.sap.engine.services.applocking.TableLockingImpl.lock(TableLockingImpl.java:139)
     at com.sap.engine.services.ejb.entity.pm.lock.TableLockingSystem.write(TableLockingSystem.java:82)
     at com.sap.engine.services.ejb.entity.pm.UpdatablePersistent.create(UpdatablePersistent.java:242)
     at com.nexeninc.seismic.ejb.SeisSetBean0Persistent.create(SeisSetBean0Persistent.java:703)
     at com.nexeninc.seismic.ejb.SeisSetBean0PM.ejbCreate(SeisSetBean0PM.java:370)
     at com.nexeninc.seismic.ejb.SeisSetLocalHomeImpl0.create(SeisSetLocalHomeImpl0.java:334)
     at com.nexeninc.seismic.ejb.SeismicServicesBean.registerDataSet(SeismicServicesBean.java:253)
     at com.nexeninc.seismic.ejb.SeismicServicesLocalLocalObjectImpl0.registerDataSet(SeismicServicesLocalLocalObjectImpl0.java:775)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:324)
     at com.sap.engine.services.webservices.runtime.EJBImplementationContainer.invokeMethod(EJBImplementationContainer.java:126)
     at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:157)
     at com.sap.engine.services.webservices.runtime.RuntimeProcessor.process(RuntimeProcessor.java:79)
     at com.sap.engine.services.webservices.runtime.servlet.ServletDispatcherImpl.doPost(ServletDispatcherImpl.java:92)
     at SoapServlet.doPost(SoapServlet.java:51)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
     at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
     at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
     at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
     at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
     at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
     at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
     at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
     at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
     at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
     at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
     at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
     at java.security.AccessController.doPrivileged(Native Method)
     at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
     at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
My compund primary key class has two attributes and those are the only ones in my table.
Please note that I'm on SP 16. I'll post the details of the compound primary key class, ejbCreate method in the next post.

Here is the code I'm using.
Session Bean code:
SeisSetLocal seisSet = seisSetHome.create("10002", "SEIS_ACQTN_SURVEY");
Entity Bean code:
public SeisSetPK ejbCreate(String seisSetId, String seisSetType)
          throws CreateException {
          setSeisSetId(seisSetId);
          setSeisSetType(seisSetType);
          SeisSetPK seisSetPK = new SeisSetPK();
          return seisSetPK;
SeisSetPK class code:
package com.nexeninc.seismic.ejb;
import java.io.Serializable;
public class SeisSetPK implements Serializable {
     private static final boolean DEBUG = false;
     public String seisSetId;
     public String seisSetType;
     public boolean equals(Object another) {
          if (another instanceof SeisSetPK) {
               SeisSetPK that = (SeisSetPK) another;
               if (!this.seisSetId.equals(that.seisSetId)) {
                    return false;
               if (!this.seisSetType.equals(that.seisSetType)) {
                    return false;
               return true;
          return false;
     public int hashCode() {
          int result = 0;          
          result += seisSetId.hashCode();
          result += seisSetType.hashCode();
          return result;

Similar Messages

  • CMP entity bean with compound primary key

    I'm trying to use a compound primary key in a CMP entity bean. I've created the custom primary key class okay, and I have the prim-key-class set in ejb-jar.xml. My client app gets the home reference okay, but when it tries to find an entity, I get the exception "SQLException: Incorrect syntax near '/'."
    I think I'm having trouble deploying this in OC4J. Is there a sample orion-ejb-jar.xml deployment for a custom, compound primary key somewhere?
    Many thanks for any help.
    Ernie

    Never mind. I solved my problem. Thanks.

  • Problem With Compound Primary Key

    Hello Experts,
      i am facing some probelm with copound primarykey.
      the Probelm is
    i have data base table which has compound primary key  for that one i have created the entity bean(CMP) and primary key of type compound.using this i am able to insert record into databse but for updation i am using
    <b>findbyPrimarykey()</b> method ,for that methos i am passing
    primary key object with compound key values.
    when i am executing this methos it is throwing <b>nosuchobject exception.</b>
    what might be the problem
    any help will be appriciated
    thanks in advance
    With Regds
    Naidu

    Hi,
    Is ur compound primarykey class is something like this?
    public class PrimaryKey implements java.io.Serializable {
          public String id = "";
          public int no = 0;
          //a default constructor is required:
          public PrimaryKey() { }
          // optional constructor fo clients:
          public PrimaryKey(String id, int no) {
               this.id = smsId;
               this.no = no;
          public String toString() {
               return id + "" + no;
         public boolean equals(Object obj) {
              if (obj == null || !(obj instanceof PrimaryKey))
                      return false;
                   else if ((((PrimaryKey)obj).no == no) && (((PrimaryKey)obj).id.equals(id)))
                      return true;
                   else
                      return false;     
          public int hashCode() {
                return id.hashCode() + no ;

  • Is it possible to create many primary key for a table?

    hello sir/mam.
    i am selva, i am new to abap,
    is it possible to create many primary key for a table?
    please guide me.

    Hi Selva,
    Many Primary Keys = Composite Key.
    i.e some set of columns will enable you to identify a unique row from a set of rows in the table.
    This can be achieved by checking the primary key check box in se11.
    Hope it helps.
    Regards,
    Maheswaran.B
    Message was edited by: Maheswaran B

  • Creating a primary key with the parallel option and the tablespace option

    I know I can create a unique index with these options and then make the primary key with the "using index" clause. anyway to do this and skip the create unique index and just create the primary key ?

    SQL> ALTER TABLE t
      2  ADD CONSTRAINT pk_t
      3  PRIMARY KEY (testcol)
      4  USING INDEX
      5  TABLESPACE example
      6  PARALLEL (DEGREE 2);
    PARALLEL (DEGREE 2)
    ERROR at line 6:
    ORA-03001: unimplemented featureYou can name the tablespace but you must do an alter index thereafter.

  • Can I create constraints "Primary key - Foreign key" on materialized views?

    Hello!
    Can I create constraints "Primary key - Foreign key" on materialized views like on tables?
    My purpose - is to make DB schema "COPY" with set of materialized views or tables, which take data from time to time from other tables situated.into another schema "ORIGINAL".
    Also - I want to use reporting tool, like Crystal Reports, to make nice reports from schema "COPY". To make nice reports, I need primary-foreign relationships between materialized views or tables in schema "COPY".
    Is it possible to use materialized views?
    Or I should use only tables to get such result?
    Thank you in advance.
    Edited by: kogotok1 on Dec 3, 2010 5:01 PM

    What happens when you try it? Or search the manuals.
    http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/statements_6002.htm#i2105365
    http://download.oracle.com/docs/cd/E11882_01/server.112/e10706/repmview.htm#REPLN360

  • Problem with update of BLOB field in a table with compound primary key

    Hi,
    I've been developing an application in Application Express 3.1.2.00.02 that includes processing of BLOB data in one of the tables (ZPRAVA). Unfortunately, I've come across a strange behaviour when I tried to update value in a BLOB field for an existing record via a DML form process. Insert of a new record including the BLOB value is OK (the binary file uploads upon submiting the form without any problems). I haven't changed the DML process in any way. The form update process used to work perfectly before I'd included the BLOB field. Since than, I keep on getting this error when trying to update the BLOB field:
    ORA-20505: Error in DML: p_rowid=3, p_alt_rowid=ID, p_rowid2=CZ000001, p_alt_rowid2=PR_ID. ORA-01008: not all variables bound
    Unable to process row of table ZPRAVA.
    OK
    Some time ago, I've already created another application where I used similar form that operated on a BLOB field without problems. The only, but maybe very important, difference between both the cases is that the first sucessfull one is based on a table with a standard one-column primary key whereas the second (problematic one) uses a table with compound (composite) two-column PK (two varchar2 fields: ID, PR_ID).
    In both cases, I've followed this tutorial: [http://www.oracle.com/technology/obe/apex/apex31nf/apex31blob.htm]).
    Can anybody confirm my suspicion that Automatic Row Processing (DML) can be used for updating BLOB fields within tables with only single-column primary keys?
    Thanks in advance.
    Zdenek

    Is there a chance that the bug will be included in the next patch?No, this fix will be in the next full version, 3.2.
    Scott

  • Composite primary key in ejb

    Hi all,
    I am new to ejb. I am trying to create a BMP bean for a particular table which is having composite primary key. I made a primary key class for that and I have done all the important things required for creating such a class viz,
    1) implement java.io.Serializable
    2) define all fields of the primary key as public variables in the class
    3) override public int hashCode()
    and public boolean equals (Object obj)
    but when i deploy the beans in jboss it is giving
    "The primary key class must override equals()" error
    what could be the problem
    Thanks in advance
    Binny

    Add a method boolean equals(Object o) see java.lang.Object. This is required for comparisons, also hashCode needed.

  • How to create one primary key for each vendor

    Hi all
    i am doing IDOC to jdbc scenario
    i am triggering idoc from R/3 and the data is going into DB table vendor through XI.
    structures are as follows:
    sender side: ZVendorIdoc (this is a customized IDOC , if i triger IDOC for multiple vendors then it triggers only 1 idoc with multiple segment )
    Receiver side:
    DT_testVendor
        Table
            tblVendor
                action UPDATE_INSERT
                access                     1:unbounded
                    cVendorName         1
                    cVendorCode        1
                    fromdate                1
                    todate                    1
                 Key1
                    cVendorName         1
    if i trigger idoc for multiple vendors ,for example vendor 2005,2006 and 2010 . then i can see that the only key comes from the very first field (2005) and the whole record for vendor 2005,2006 and 2010  goes into the table with this(2005) as a primary key
    now again if i send data for these three vendor 2005, 2006 , 2010, in which record for the vendor 2005 is same and for 2006 and 2010 are different than it takes 2005 as a primary key and it does not update the data in the table.
    my requirement is like this:   for each vendor there should be one unique key assigned.
                                              for above said example there should come three keys one for each vendor .
    could you please help me how to do this???????????

    Hi,
      In Mapping Make the statement is 0-unbounded.For each vendor create a statement.This will solve your problem.
    Regards,
    Prakasu.M

  • Calling a page after creating a primary key?

    Hello,
    I have a form on a table with a create button on it. The primary key is created after I click the CREATE button, and brings me back to the report which shows my new record. Everything is fine here.
    Now, I want to branch to a new page (after processing), while passing the value of my new primary key to this page. But it seems that this value is null (if I look in the URL there's no value)
    For example, I need to create a new Client, and pass the primary key of my client to a new page. But it doesn't work... anybody can help me?
    Thanks,
    Mathieu

    Never, EVER use the current value + 1!!! You will at some point, run into a collision, where two records are trying to use the same primary key value!
    If you are using a surrogate PK, then you may want to consider using an Oracle sequence and trigger to populate that value. If you create a simple table via SQL Workshop, APEX will create not only a table, but the associated sequence and trigger; have a look at that if you have not seen this in action.
    If you prefer to not use a trigger, then yes, you can have a computation that sets the value of P4_NOCLIENT to the next value of the sequence - NOT the current value + 1. Once it's set in APEX session state, the rest is pretty simple.
    Thanks,
    &#150; Scott &#150;
    http://spendolini.blogspot.com/
    http://sumnertech.com/

  • How can I use the SQL to create a primary key for a existing table?

    create table a(bm number,mc varchar2(20));
    when the table was created,i want to make the column bm as
    the primary key and my SQL is "alter table a enable primary key bm",the system show
    me error,how can I write the right one?

    create table a(bm number,mc varchar2(20));
    when the table was created,i want to make the column bm as
    the primary key and my SQL is "alter table a enable primary key bm",the system show
    me error,how can I write the right one? You do not have any primary key defined on your table yet, so, it does not make sense to enable it (if at all possible) !
    You need to add PRIMARY KEY using something like this:
    SQL> alter table a add constraint pk_a_bm primary key (bm) ;

  • How to create a primary key by 2 columns in sql??

    as title
    thx a lot.

    Chris,
    Well you have two basic ways. One is to issue an alter table command and define a PRIMARY KEY (also called a PK). The other is to create a UNIQUE index. The PRIMARY KEY creates an index anyway, though I prefer to just use unique indexes as you can specify more options in this manner. A table can only have 1 PK where as you can have multiple UNIQUE indexes. I also do not combine the PK definition directly into the CREATE TABLE command, as normally one would keep a seperate PK script, even if they did contain only unique indexes commands and not PK alter table commands.
    Anyway, below are the two methods of making a PK/Unique object for your table. The table name used here is T1 ...
    Method #1 (Primary Key)
    ALTER TABLE T1 DROP PRIMARY KEY;
    ALTER TABLE T1 ADD PRIMARY KEY
    (Column_1,Column_2, ...)
    STORAGE
         NEXT 512K
         MINEXTENTS 1
         MAXEXTENTS UNLIMITED
         PCTINCREASE 0
    Method #2 (preferred) : Unique Index
    DROP INDEX PK_T1;
    CREATE UNIQUE INDEX PK_T1 ON T1
    (Column_1,Column_2, ...)
    TABLESPACE INDX
    PCTFREE 10
    STORAGE
         INITIAL 1M
         NEXT 512K
         MINEXTENTS 1
         MAXEXTENTS UNLIMITED
         PCTINCREASE 0
    It's always best to define the storage clause for both the create table and it's indexes.
    Hope this helps ya,
    Tyler

  • How to create a primary key

    Hello - New to Oracle and was wondering what is a good way to create an auto-incrementing primary key for a table. I have done this so far:
    Created a new sequence cst_swq begin with 1 increment by 1.
    CREATE OR REPLACE TRIGGER CST_TRIG
    BEFORE INSERT
    ON COOKIE_SALES
    REFERENCING NEW AS NEW
    FOR EACH ROW
    BEGIN
    SELECT CST_SEQ.nextval INTO NEW.SALE_ID FROM dual;
    This does not really work for me. Help with the code or a better idea to create primary key is much appreciated, thank you.

    adi26 wrote:
    This does not really work for me. What does that mean?
    In which way does this approch not meet your requirements?
    BTW: after 200+ posts you should have learned how to use tags...
    bye
    TPD                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How can I be able to create a primary key in a Form on a Table with Report?

    When I click the "Create" button, a form appears allowing me type in data for those columns. But primary key is not there. I really need to specify my primary key here also. Because the primary key for this table is a Serial Number, not just a sequence number.
    I noticed that when I created this page earlier, the primary key was ruled out by default. I wish there is a way to accomplish this. Thanks!

    Hello,
    >> a pk field is not null implicit …
    I’m not sure I understand your statement. Every item, including the one holds the primary key, is null for a new form. The question is, when you are filling the form, how to populate this field. The APEX wizard assumes this field will be populated by the system, hence it hides it from the user, however it’s a valid situation where the primary field is filled by the user.
    As primary field should not be changed, hence the productive advice by Martin. If the form displays an existing record, the primary field item should be set to Read Only.
    Regards,
    Arie.
    Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.

  • Insert values of form on a table with compound primary keys in APEX

    Good evening,
    I have a table with compoud primay keys. On ER model I had a many to many relation and when I coverted to relational model I've got a table with the primary keys of the two entities.
    My problem now is that I am trying to build an APEX application with a Form/Report and I want to insert a tuple both on the "entity" and on the table with two primary keys.
    I created a trigger with
    CREATE OR REPLACE TRIGGER ins_key_elem
    INSTEAD OF INSERT
    ON v_key_elem
    REFERENCING NEW AS NEW
    FOR EACH ROW
    BEGIN
    INSERT INTO elem_type (elem_key, type_key)
    VALUES (:NEW.elem_key, :NEW.type_key);
    INSERT INTO elem(elem_key, name)
    VALUES (:NEW.elem_key, :NEW.name);
    END;
    Is that ok? If it is, now how I can use that trigger to do what I need? i.e. insert the tuple on the two tables when I use the create button of the form
    Edited by: 934530 on May 15, 2012 2:36 PM

    Nevermind...figured it out. Was able to set the value on the Report Attributes page.

Maybe you are looking for