Composite Primary Key Error

I am using Sun One App Server PE8.
I have a class with a composite primary key field. When I place the following method in my Home interface:
public MyEjb findByPrimaryKey(MyEjbPrimaryKey pk) throws FinderException, RemoteException;I get the following error when deploying:
ejbFindByPrimaryKey(EjbPrimaryKey) is already defined in MyEjb1368202910_ConcreteImpl
    public MyEjbPrimaryKey ejbFindByPrimaryKey (MyEjbPrimaryKey key)However, If i remove this method from the Home interface, i get the following error when running the verification tool:
Error: No single arg findByPrimaryKey(PrimaryKeyClass) method was found in home interface class [ MyEjb ].However, I can still deploy the EAR successfully.
Another related symptom of this problem, is if I include the following method in my Home interface:
public MyEjb findByPrimaryKey(String pkField1, String pkField2) throws FinderException, RemoteException;And call this method, I get the following exception at runtime:
java.rmi.RemoteException: Bean class for ejb [MyEjb] does not define a method corresponding to [Home] interface method [public abstract MyEjb MyEjbHome.findByPrimaryKey(java.lang.String,java
.lang.String) throws javax.ejb.FinderException,java.rmi.RemoteException]I get these same problems with all EJB's that use composite keys. Has anyone else had this problem?
Thanks
toby

This is a CMP bean, with no ejbFindByPrimaryKey in the Bean class. Below, i have included the Home interface and the Bean class (with unneccessary code removed)
Thanks for looking at this for me.
BEAN CLASS
package lands.mc.bus.prod;
import java.rmi.*;
import java.util.*;
import javax.ejb.*;
public abstract class TopoMapBean implements EntityBean
  private EntityContext entity;
  public TopoMapBean()
  public void setEntityContext(EntityContext ctx)
    entity = ctx;
  public void unsetEntityContext()
    entity = null;
  public TopoMapPrimaryKey ejbCreate(String mapName, String mapNumber, String mnemonic,String edition, String scale)
  throws CreateException
    // call setters...
    return null;
  public void ejbPostCreate( String mapName,
                                               String mapNumber,
                                         String mnemonic,
                                         String edition,
                                         String scale )
  removed set/get methods
  public void ejbStore() {}
  public void ejbLoad() {}
  public void ejbActivate() {}
  public void ejbPassivate() {}
  public void ejbRemove() {}
}HOME INTERFACE
package lands.mc.bus.prod;
import java.rmi.*;
import java.util.*;
import javax.ejb.*;
public interface TopoMapHome extends EJBHome
  public TopoMap create(String mapName,
                        String mapNumber,
                        String mnemonic,
                        String edition,
                        String scale
  throws CreateException, RemoteException;
  public TopoMap findByPrimaryKey(String mapNumber, String edition) throws FinderException, RemoteException;
// doesnt deploy with this signature
//  public TopoMap findByPrimaryKey(TopoMapPrimaryKey pkey) throws FinderException;
// have to use this method instead of findByPrimaryKey(String, String) above
  public TopoMap findTopoMap(String mapNumber, String edition) throws FinderException, RemoteException;

Similar Messages

  • Error While Deploying A CMP Entity Bean With A Composite Primary Key

    Hello all,
    I have a problem deploying CMP Entity beans with composite primary keys. I have a CMP Entity Bean, which contains a composite primary key composed of two local stubs. If you know more about this please respond to my post on the EJB forum (subject: CMP Bean Local Stub as a Field of a Primary Key Class).
    In the mean time, can you please tell me what following error message means and how to resolve it? From what I understand it might be a problem with Sun ONE AS 7, but I would like to make sure it's not me doing something wrong.
    [05/Jan/2005:12:49:03] WARNING ( 1896):      Validation error in bean CustomerSubscription: The type of non-static field customer of the key class
    test.subscription.CustomerSubscriptionCMP_1530383317_JDOState$Oid must be primitive or must implement java.io.Serializable.
         Update the type of the key class field.
         Warning: All primary key columns in primary table CustomerSubscription of the bean corresponding to the generated class test.subscription.CustomerSubscriptionCMP_1530383317_JDOState must be mapped to key fields.
         Map the following primary key columns to key fields: CustomerSubscription.CustomerEmail,CustomerSubscription.SubscriptionType. If you already have fields mapped to these columns, verify that they are key fields.Is it enough that a primary key class be serializable or all fields have to implement Serializable or be a primitive?
    Please let me know if you need more information to answer my question.
    Thanks.
    Nikola

    Hi Nikola,
    There are several problems with your CMP bean.
    1. Fields of a Primary Key Class must be a subset of CMP fields, so yes, they must be either a primitive or a Serializable type.
    2. Sun Application Server does not support Primary Key fields of an arbitrary Serializable type (i.e. those that will be stored
    as BLOB in the database), but only primitives, Java wrappers, String, and Date/Time types.
    Do you try to use stubs instead of relationships or for some other reason?
    If it's the former - look at the CMR fields.
    If it's the latter, I suggest to store these fields as regular CMP fields and use some other value as the PK. If you prefer that
    the CMP container generates the PK values, use the Unknown
    PrimaryKey feature.
    Regards,
    -marina

  • Composite Primary Key Mapping error

    I have the following code:
    public class PreviousStepEJB3PK implements Serializable {
    private static final long serialVersionUID = 3024775815042084864L;
    public Long id;
    public Long previousId;
    public PreviousStepEJB3PK() {
    public PreviousStepEJB3PK(Long id, Long previousId) {
    this.id = id;
    this.previousId = previousId;
    public boolean equals(Object other) {
    if (other instanceof PreviousStepEJB3PK) {
    final PreviousStepEJB3PK otherPreviousStepPK = (PreviousStepEJB3PK) other;
    final boolean areEqual = (otherPreviousStepPK.id.equals(id) && otherPreviousStepPK.previousId.equals(previousId));
    return areEqual;
    return false;
    public int hashCode() {
    return super.hashCode();
    @Entity
    @Table(name = "OS_CURRENTSTEP_PREV")
    @NamedQuery(name = "findById",
         query = "select object(o) from PreviousCurrentStepEJB3 o where o.id = ?1")
    @IdClass(PreviousStepEJB3PK.class)
    public class PreviousCurrentStepEJB3 implements Serializable {
    private static final long serialVersionUID = 1717698904412346878L;
    @Id
    @Column(name = "ID", nullable = false)
    private Long id;
    @Id
    @Column(name = "PREVIOUS_ID", nullable = false)
    private Long previousId;
    public PreviousCurrentStepEJB3() {
    I´m using eclipse to deploy my application over an OC4J. When I launch the deploy I have the following error:
    07/07/05 11:42:47 Caused by: Exception [TOPLINK-7150] (Oracle TopLink Essentials - 2006.8 (Build 060829)): oracle.toplink.essentials.exceptions.ValidationException
    Exception Description: Invalid composite primary key specification. The names of the primary key fields or properties in the primary key class [ar.com.eds.mcd.fawkes.model.PreviousStepEJB3PK] and those of the entity bean class [class ar.com.eds.mcd.fawkes.model.PreviousCurrentStepEJB3] must correspond and their types must be the same. Also, ensure that you have specified id elements for the corresponding attributes in XML and/or an @Id on the corresponding fields or properties of the entity class.
    07/07/05 11:42:47      at oracle.toplink.essentials.exceptions.ValidationException.invalidCompositePKSpecification(ValidationException.java:995)
    07/07/05 11:42:47      at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataValidator.throwInvalidCompositePKSpecification(MetadataValidator.java:119)
    07/07/05 11:42:47      at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.ClassAccessor.validatePrimaryKey(ClassAccessor.java:1463)
    07/07/05 11:42:47      at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.ClassAccessor.process(ClassAccessor.java:463)
    07/07/05 11:42:47      at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProcessor.processAnnotations(MetadataProcessor.java:196)
    07/07/05 11:42:47      at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.processORMetadata(EntityManagerSetupImpl.java:993)
    07/07/05 11:42:47      at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:501)
    07/07/05 11:42:47      at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createContainerEntityManagerFactory(EntityManagerFactoryProvider.java:152)

    I ran into a similar problem. I was able to work around it by putting the @Id annotations on the accessors for the primary key fields rather than on the fields themselves. This seems like a bug to me.

  • Toplink Essentials + Composite Primary Key Mapping Error

    Exception [TOPLINK-7150] (Oracle TopLink Essentials - 2006.8 (Build 060829)): oracle.toplink.essentials.exceptions.ValidationException
    Exception Description: Invalid composite primary key specification. The names of the primary key fields or properties in the primary key class [ar.com.eds.mcd.fawkes.model.PreviousStepEJB3PK] and those of the entity bean class [class ar.com.eds.mcd.fawkes.model.PreviousCurrentStepEJB3] must correspond and their types must be the same. Also, ensure that you have specified id elements for the corresponding attributes in XML and/or an @Id on the corresponding fields or properties of the entity class.
    Is it a Toplink bug?
    I have the following code:
    public class PreviousStepEJB3PK implements Serializable {
    private static final long serialVersionUID = 3024775815042084864L;
    public Long id;
    public Long previousId;
    public PreviousStepEJB3PK() {
    public PreviousStepEJB3PK(Long id, Long previousId) {
    this.id = id;
    this.previousId = previousId;
    public boolean equals(Object other) {
    if (other instanceof PreviousStepEJB3PK) {
    final PreviousStepEJB3PK otherPreviousStepPK = (PreviousStepEJB3PK) other;
    final boolean areEqual = (otherPreviousStepPK.id.equals(id) && otherPreviousStepPK.previousId.equals(previousId));
    return areEqual;
    return false;
    public int hashCode() {
    return super.hashCode();
    @Entity
    @Table(name = "OS_CURRENTSTEP_PREV")
    @NamedQuery(name = "findById",
    query = "select object(o) from PreviousCurrentStepEJB3 o where o.id = ?1")
    @IdClass(PreviousStepEJB3PK.class)
    public class PreviousCurrentStepEJB3 implements Serializable {
    private static final long serialVersionUID = 1717698904412346878L;
    @Id
    @Column(name = "ID", nullable = false)
    private Long id;
    @Id
    @Column(name = "PREVIOUS_ID", nullable = false)
    private Long previousId;
    public PreviousCurrentStepEJB3() {
    I´m using eclipse to deploy my application over an OC4J. When I launch the deploy I have the following error:
    07/07/05 11:42:47 Caused by: Exception [TOPLINK-7150] (Oracle TopLink Essentials - 2006.8 (Build 060829)): oracle.toplink.essentials.exceptions.ValidationException
    Exception Description: Invalid composite primary key specification. The names of the primary key fields or properties in the primary key class [ar.com.eds.mcd.fawkes.model.PreviousStepEJB3PK] and those of the entity bean class [class ar.com.eds.mcd.fawkes.model.PreviousCurrentStepEJB3] must correspond and their types must be the same. Also, ensure that you have specified id elements for the corresponding attributes in XML and/or an @Id on the corresponding fields or properties of the entity class.
    07/07/05 11:42:47 at oracle.toplink.essentials.exceptions.ValidationException.invalidCompositePKSpecification(ValidationException.java:995)
    07/07/05 11:42:47 at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataValidator.throwInvalidCompositePKSpecification(MetadataValidator.java:119)
    07/07/05 11:42:47 at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.ClassAccessor.validatePrimaryKey(ClassAccessor.java:1463)
    07/07/05 11:42:47 at oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.ClassAccessor.process(ClassAccessor.java:463)
    07/07/05 11:42:47 at oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProcessor.processAnnotations(MetadataProcessor.java:196)
    07/07/05 11:42:47 at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.processORMetadata(EntityManagerSetupImpl.java:993)
    07/07/05 11:42:47 at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:501)
    07/07/05 11:42:47 at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.createContainerEntityManagerFactory(EntityManagerFactoryProvider.java:152)

    I ran into a similar problem. I was able to work around it by putting the @Id annotations on the accessors for the primary key fields rather than on the fields themselves. This seems like a bug to me.

  • HOW TO  GET COUNT IN OF COMPOSITE PRIMARY KEYS USING ECLIPSELINK

    Hi all,
    We are currently migrating our application form oracle 10g to 11 g and hence migrating from toplink to eclipselink.
    we are unable to fire the count query and getting the following exception ...
    Error Code: 909
    Call: SELECT COUNT() FROM T_USER_MESSAGE t0, T_USER t2, T_MESSAGE_RECIPIENT t1 WHERE ((((t2.PERSISTENT_ID = ?) AND (t2.SITE_CODE = ?)) AND (t1.DELETED_BY_RECIPIENT = ?)) AND (((t2.PERSISTENT_ID = t1.RECIPIENT_ID) AND (t2.SITE_CODE = t1.RECIPIENT_SITE)) AND ((t0.PERSISTENT_ID = t1.MESSAGE_ID) AND (t0.SITE_CODE = t1.MESSAGE_SITE))))
         bind => [13398610, 1, F]
    please advise .
    we suspect that this could be because of the composite primary key in one of the tables .
    any pointers to specify how count(*) could be used in this scenario would be of great help ..
    Thanks in advance

    What is the query being used, include the JPQL/expression code.
    What is the error message (I assume this is a database error?).
    What version are you using, can you try the latest EclipseLink 2.1 release.
    James : http://www.eclipselink.org

  • Null in Composite Primary Key and "Primary keys must not contain null"

    Hello all.
    I'm a newbie concerning to JPA/EJB3, but I was wondering if toplinks doesn't support composite primary keys with null in some field (something perfectly right in any RDBMS).
    I used JDeveloper (I'm using Oracle 10g database and JDeveloper 10.1.3.2.) wizards to generate JPA classes and I checked out generated files (with annotations), so they should be right (by the way, other O-R mappings for my model are working right, but this one).
    I'm getting the next error:
    Exception Description: The primary key read from the row [DatabaseRecord(
         TSUBGRUPOSLDI.CD_GRUP => 01
         TSUBGRUPOSLDI.CD_SUBGRUP => null
         TSUBGRUPOSLDI.CG_POBL => 058
         TSUBGRUPOSLDI.CG_PROV => 28
         TSUBGRUPOSLDI.DSCR => Sanidad)] during the execution of the query was detected to be null. Primary keys must not contain null.
    Compound primary key is (CD_GRUP, CD_SUBGRUP). No foreign keys, no joins (only a NamedQuery: "select o from ..."). It's the simplest case!
    I checked out that everything runs ok if there's no "null" value in CD_SUBGRUP.
    After some research (this and other forums) I'm beginning to believe that it's not supported, but not sure.
    Am I doing sth wrong? If not, what is the reason to not support this? Will it be supported in the future?
    Thanks in advance.

    Null is a special value and in many databases is not comparable to another null value (hence the isNull operator) and may pose problems when used to uniquely identify an Entity. TopLink does not support null values within a composite PK. As the nullable column is most likely not designated as a PK within your database table (many databases do not allow this) I recommend updating the Entity PKs to match that of the database.
    --Gordon                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • In which case composite primary key allows NULL values in it

    Hi to all
    In what case composite primary key allows nulls in it.
    Let us suppose, I created a composite primary key with 2 attributes.
    CREATE TABLE sample
    BNK_Id NUMBER(6),
    BNK_Name VARCHAR2(20),
    CONSTRAINT BNK_Id_Name_PK PRIMARY KEY(BNK_Id,BNK_Name)
    When it allows null values in it.
    thanks in advance

    Are you sure that your instructor was not talking about unique keys? As Solomon said, a primary key always implies not null on all of the columns of the PK. However a unique key does not automatically imply not null, and can have nulls in a column as long as the values in the populated columns are unique.
    SQL> create table test (
      2     id number,
      3     pid number,
      4     descr varchar2(10));
    Table created.
    SQL> alter table test add constraint test_unq
      2     unique (id, pid);
    Table altered.
    SQL> insert into test values (1, null, 'desc1');
    1 row created.
    SQL> insert into test values (2, null, 'desc2');
    1 row created.
    SQL> insert into test values (2, null, 'fail1');
    insert into test values (2, null, 'fail1')
    ERROR at line 1:
    ORA-00001: unique constraint (OPS$ORACLE.TEST_UNQ) violatedJohn

  • Urgent - ESB: DB Adapter with composite primary keys no returning any data

    I have a DB Adapter in the ESB that inserts/updates/selects data to/from a table with 2 columns as primary keys, but table has several columns.
    1. Initially, the db table had constraints for the composite primary key, The DB adapter had valid data coming in, but no result data.
    2. Then I removed the db constraints on the composite primary key, and selected the 2 columns in the DB adapter wizard. Still, valid data is going in, since I am outputing to a file prior to call this node, but no result data is appearing. The result XML is empty.
    Do I need to do something in Toplink for this?
    The table spec is below. the ACCT_FIELD and ACCT_CODE columns make up the composite primary key.
    CREATE TABLE AFF_DATA_SYNC
    ACCT_FIELD NUMBER NOT NULL,
    ACCT_CODE VARCHAR2(16) NOT NULL,
    ACCT_EXISTS_FLAG VARCHAR2(1),
    SAVE_ACCT_SEG_XML CLOB,
    LAST_UPDATE_DATE DATE
    The following xml is the request to the DB adapter:
    <top:AffDataSyncReadDBAdapterSelect_accountField_accountCodeInputParameters xmlns:top="http://xmlns.oracle.com/pcbpel/adapter/db/top/AffDataSyncReadDBAdapter">
    <top:accountField>8</top:accountField>
    <top:accountCode>0003888</top:accountCode>
    </top:AffDataSyncReadDBAdapterSelect_accountField_accountCodeInputParameters>
    Log output:
    JCA: esb:///ESB_Projects/STRIPES-AFF-Data-Intg_AFF-Data-Integration/AffDataSyncReadDBAdapter.wsdl [ AffDataSyncReadDBAdapter_ptt::AffDataSyncReadDBAdapterSelect_accountField_accountCode(AffDataSyncReadDBAdapterSelect_accountField_accountCode_inparameters,Af
    DataSyncWipCollection) ] - No XMLRecord headers provided
    JCA: <oracle.tip.adapter.db.DBInteraction executeOutboundRead> Executing query with arguments [8, 0003917]
    JCA: <oracle.tip.adapter.db.TopLinkLogger log> SELECT ACCT_FIELD, ACCT_CODE, ACCT_EXISTS_FLAG, SAVE_ACCT_SEG_XML, LAST_UPDATE_DATE FROM
    AFF_DATA_SYNC_WIP WHERE ((ACCT_FIELD = ?) AND (ACCT_CODE = ?))
    bind => [8, 0003888]
    JCA: <oracle.tip.adapter.db.DBInteraction executeOutboundRead> Read the following objects: []
    Message was edited by:
    user589357
    Message was edited by:
    user589357
    Message was edited by:
    user589357
    Message was edited by:
    user589357

    The Toplink has no errors. Now I changed my table with only a single primary key, but for some reason, I am still getting no data.
    JDeveloper 10.1.3.3 / SOA Suite (only using ESB) 10.1.3.3 with Oracle DB 10g 10.2.0.3.
    1. What does No XMLRecord headers found mean?
    2. Notice the last log item; Read ... []
    Here are the log contents:
    Invoking next service "AffDataSyncReadDBAdapterSelect_recordId" with payload :
    <top:AffDataSyncReadDBAdapterSelect_recordIdInputParameters xmlns:top="http://xmlns.oracle.com/pcbpel/adapter/db/top/AffDataSyncReadDBAdapter">
    <top:recordId>80003888</top:recordId>
    </top:AffDataSyncReadDBAdapterSelect_recordIdInputParameters>
    JCA: esb:///ESB_Projects/STRIPES-AFF-Data-Intg_AFF-Data-Integration/AffDataSyncReadDBAdapter.wsdl [ AffDataSyncReadDBAdapter_ptt::AffDataSyncReadDBAdapterSelect_recordId(AffDataSyncReadDBAdapterSelect_recordId_inparameters,AffDataSyncWipCollection)
    ] - No XMLRecord headers provided
    JCA: esb:///ESB_Projects/STRIPES-AFF-Data-Intg_AFF-Data-Integration/AffDataSyncReadDBAdapter.wsdl [ AffDataSyncReadDBAdapter_ptt::AffDataSyncReadDBAdapterSelect_recordId(AffDataSyncReadDBAdapterSelect_recordId_inparameters,AffDataSyncWipCollection)
    ] - Starting JCA LocalTransaction
    JCA: esb:///ESB_Projects/STRIPES-AFF-Data-Intg_AFF-Data-Integration/AffDataSyncReadDBAdapter.wsdl [ AffDataSyncReadDBAdapter_ptt::AffDataSyncReadDBAdapterSelect_recordId(AffDataSyncReadDBAdapterSelect_recordId_inparameters,AffDataSyncWipCollection)
    ] - Invoking JCA Outbound Interaction
    JCA: <oracle.tip.adapter.db.DBInteraction executeOutboundRead> executing the NamedQuery: AffDataSyncReadDBAdapter.AffDataSyncWip.AffDataSyncReadDBAdapterSelect
    JCA: <oracle.tip.adapter.db.DBInteraction executeOutboundRead> Parsing header record element.
    JCA: <oracle.tip.adapter.db.TopLinkLogger log> client acquired
    JCA: <oracle.tip.adapter.db.DBInteraction executeOutboundRead> Executing query with arguments [80003888]
    JCA: <oracle.tip.adapter.db.TopLinkLogger log> SELECT RECORD_ID, ACCT_FIELD, ACCT_CODE, ACCT_EXISTS_FLAG, SAVE_ACCT_SEG_XML, LAST_UPDATE_DATE
    FROM AFF_DATA_SYNC_WIP WHERE (RECORD_ID = ?)
    bind => [80003888]
    JCA: <oracle.tip.adapter.db.DBInteraction executeOutboundRead> Read the following objects: []
    Message was edited by:
    user589357
    Message was edited by:
    user589357

  • 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.

  • Composite Primary Key in Form

    Hi, I have a table which maintains versions. This has a composite primary key - eg - Company_id + version_no. I tried creating a form based on a template with Primary key as Company_id and primary key column 2 as Version_no. When I try to run the form it gives an error, 'Invalid number' on the process in Rendering page. When i remove the second primary key the results are displayed correctly (however I have a problem when there are more than 1 versions - too many rows).
    How do I create a form based on a template with a composite key.
    How can I create a form which has more than 2 keys as part of a composite primary key.

    This thread is old....but let me make some notice...
    Oracle guys,
    does all that mean that you encourige using simple PK which is based on sequence, regardless that involve unique index on columns that normaly represent PK, but in master detail wizard it is impossible to use composite keys?
    Why I'm asking this?
    Because many apps are translated to HTMLDB (Oracle based) directly with not too much problems. But if we have to change PK then many things are complicated...
    This all come from a problem how to fill detail table PK where first coulmn represent master key field and second one is filled with user input-nothing can be automated.
    In your demo I saw that for "orders-order items" you use "simple PK" technique, regardless order items could have PK made from (OrderId, Id)...
    Please make some respond for this....
    THX!

  • How to persist an entity with Composite primary key

    Problem Statement:-
    Entity A have many to one relation with Entity C
    Entity B have many to one relation with Entity C
    Entity C have a composite primary key of (Entity A PK & Entity B PK)
    A --< C
    B --< C
    the entites are automatic generated by Dali tool
    @Entity
    public class C implements Serializable
         @EmbeddedId
         private C.PK pk;
         private int attribute;
         //Code
         @Embeddable
         public static class PK implements Serializable
              public int A_Id;
              public int B_Id;
              //Code
    @Entity
    public class A implements Serializable
         @Id
         private int AId;
         @OneToMany
         private Set<C> C_Collection;
         //Code
    @Entity
    public class B implements Serializable
         @Id
         private int BId;
         @OneToMany
         private Set<C> C_Collection;
         //Code
    i made a session Bean which add a new entity C
    Session
         A a = em.find(A.class, AId);
         B b = em.find(B.class, BId);
         C c = new C();
         C.PK pk = new C.PK();
         pk.AId(a.getID());
         pk.BId(b.getID());
         c.setPk(pk);
         c.setA(a);
         c.setB(b);
         c.setAttribute(12);
         em.persist(c);
    when running this code an exception is raised
    Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2006.8 (Build 060830)): oracle.toplink.essentials.exceptions.DatabaseException
    Internal Exception: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: Unknown column 'A_ID' in 'field list'Error Code: 1054
    Call:INSERT INTO C (attribute, Aid, A_ID, B_ID, Bid) VALUES (?, ?, ?, ?, ?)
         bind => [2, 6, 6, 1, 1]
    this is logic as Table "C" has only 3 coloumns only "attribute" , "Aid" , "Bid"
    but the mapping is different as it adds the composite PK attributes to the insert statement
    if there is a sample code or how to solve this issue it would be great

    Hello Juwen,
    The problem is you are registering an object, assigning it a null pk, and then commiting the uow/transaction. TopLink uses registered objects to keep track of changes you make inorder to persist those changes on commit. So the simple fix is to not commit the UnitOfWork - call release() on it instead.
    Another solution is to use the session copyObject api. The simple form that only takes an object will work similar to registering the object as it will copy all persistent attributes but it will leave the primary key null. You can also use this method to specify a copyPolicy to customize the process. Using this method will be a bit more efficient, since a UOW makes both a working copy and a back up copy of objects registered, inorder to keep track of changes. Using the copyObject api will only make a single copy.
    Best Regards,
    Chris

  • Composite Primary Key question

    I have a new question regarding composite primary keys on another table I have created.
    I have the following table with the following definition:
    CREATE TABLE "APSOM"."CPULIST"
    ( "CPU_ID" VARCHAR2(10 BYTE),
    "SERVER_ID" VARCHAR2(10 BYTE),
    "CREATED_DATETIME" TIMESTAMP (6),
    "UPDATED_DATETIME" TIMESTAMP (6)
    with the following composite PK definition:
    ALTER TABLE "APSOM"."CPULIST" ADD CONSTRAINT "CPULIST_PK" PRIMARY KEY ("CPU_ID", "SERVER_ID")
    Then, I inserted data in the following way:
    insert into CPULIST
    values ('CPU1', 'P1', SYSDATE, SYSDATE);
    with following CPU ID values from 'CPU1' to 'CPU16' for SERVER ID value 'P1' also inserted as well.
    Now, I am trying to insert values for SERVER ID value 'P2'
    insert into CPULIST
    values ('CPU1', 'P2', SYSDATE, SYSDATE);
    and I am getting the following error message:
    Error starting at line 1 in command:
    insert into CPULIST
    values ('CPU1', 'P2', SYSDATE, SYSDATE)
    Error report:
    SQL Error: ORA-00001: unique constraint (APSOM.XPKCPULIST) violated
    00001. 00000 - "unique constraint (%s.%s) violated"
    *Cause: An UPDATE or INSERT statement attempted to insert a duplicate key.
    For Trusted Oracle configured in DBMS MAC mode, you may see
    this message if a duplicate entry exists at a different level.
    *Action: Either remove the unique restriction or do not insert the key.
    Using the following SQL command:
    select column_name from all_cons_columns
    where constraint_name = 'CPULIST_PK'
    and owner = 'APSOM';
    I get the following records
    1. CPU_ID
    2. SERVER_ID
    This error does not make sense to me. Any help would be appreciated.
    Thanks,
    Patrick Quinn
    Operations
    Turning Point Global Solutions

    So, if there is a hidden unique constraint XPKCPULIST that cannot be pulled the all_cons_column table and I drop the XPXCPULIST constraint with the following SQL:
    alter table CPULIST drop constraint XPKCPULIST;
    Error starting at line 1 in command:
    alter table CPULIST drop constraint XPKCPULIST
    Error report:
    SQL Error: ORA-02443: Cannot drop constraint - nonexistent constraint
    02443. 00000 - "Cannot drop constraint - nonexistent constraint"
    *Cause:    alter table drop constraint <constraint_name>
    *Action:   make sure you supply correct constraint name.
    What can I do to get past this so I can perform the following insert and receive this error message??
    insert into CPULIST
    values ('CPU1', 'P2', SYSTIMESTAMP, SYSTIMESTAMP);
    Error starting at line 1 in command:
    insert into CPULIST
    values ('CPU1', 'P2', SYSTIMESTAMP, SYSTIMESTAMP)
    Error report:
    SQL Error: ORA-00001: unique constraint (APSOM.XPKCPULIST) violated
    00001. 00000 - "unique constraint (%s.%s) violated"
    *Cause:    An UPDATE or INSERT statement attempted to insert a duplicate key.
    For Trusted Oracle configured in DBMS MAC mode, you may see
    this message if a duplicate entry exists at a different level.
    *Action:   Either remove the unique restriction or do not insert the key.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Reconciling composite primary key tables in 9.0.1.4 DB app connector

    Hi
    I am trying to get the reconciliation in the 9.0.1.4 db app connector to work on a view that has a composite primary key (one user_id field and one group_id field)
    There are no examples on how to do this and my "trial-and-error" efforts have not been fruitful this far. Anyone that has any experience of how to solve this problem?
    Best regards
    /Martin

    Hi Martin, our customer is also very sensitive to changes in his HR system, it is a custom oracle development. He provide us a read only view every day with all changes on their identities. We have developed a custom pl/sql proccess to fill a custom local table with the right information . Then we use this table locally with dbtable connector but with some custom addons.
    So i believe that using a second table and keep in synch it is the best approach.
    We have detect some problem with 9.0.1.4 DB app connector, it is using internally only one db connection for all its operations, in a huge load condition its can produce errors and race condition problems. We have a custom connector now and it is using connection pool from application server so we will have not this problem.
    I believe that oracle should release source for their connectors, i am very sure that partners and customers can improve it.

  • Can a composite primary key column be null

    Hi All,
    It will be a silly question but still I would like to ask can a composite primary key column be null?
    Thanks,
    Rafi.

    Rafi,
    Why you think it would be allowed?
    SQL> drop table test purge;
    drop table test purge
    ERROR at line 1:
    ORA-00942: table or view does not exist
    SQL> create table test as select * from dba_objects;
    Table created.
    SQL> alter table test add primary key(object_id, owner);
    Table altered.
    SQL> insert into test(object_id, owner) values(null, 'aman');
    insert into test(object_id, owner) values(null, 'aman')
    ERROR at line 1:
    ORA-01400: cannot insert NULL into ("SYS"."TEST"."OBJECT_ID")
    SQL> insert into test(object_id, owner) values(1,null);
    insert into test(object_id, owner) values(1,null)
    ERROR at line 1:
    ORA-01400: cannot insert NULL into ("SYS"."TEST"."OWNER")
    SQL>HTH
    Aman....

  • Application Translation Not Working - Primary Key Error

    I had created an application translation to Spanish but it wasn't displaying my Spanish translation. I was going to try and redo it so I tried creating a new mapping and then seeding the translatable text. I got a primary key error "ORA-20001: Seed insert error: WWV_FLOW_TOPLEVEL_TABS.TAB_TEXT ORA-00001: unique constraint (FLOWS_030100.WWV_FLOW_TRANSLATABLE_TEXT_PK) violated".
    I went in and deleted what I had done through APEX for this app and tried to create a new application but still get the primary key error when I try to seed it. I gave it a new translated application ID but that doesn't seem to help. Anyone have this problem or no of the reason I'm having this issue?
    Thanks.

    Hi David,
    Thanks for reporting this. This was an interesting problem to solve.
    As it turns out, it was a logic error in Application Express (i.e., bug). When deleting a translation mapping, the associated strings in the translation repository would be deleted for that application, but if and only if you had actually published the application.
    I think this is why you could never get Spanish working properly - you had never actually published the application the first time. So I'll bet what you did is deleted the original mapping, then you recreated the mapping for the same language but with a different translated application ID. Since you had never published the application from the original translation mapping, and there were orphaned rows in the translation repository, you encountered a "collision" when you tried to seed the second time with the different translated application ID.
    Your action of deleting rows from WWV_FLOW_TRANSLATABLE_TEXT$ cleaned up these orphaned rows. As you stated, this isn't recommended to perform DML on the underlying APEX tables. A couple alternatives could have been:
    1) Before deleting the translated application mapping, actually publish the application and then delete the mapping.
    2) If you had deleted the mapping already, you could recreate the mapping for the same language and with the original translated application ID. Then, publish the application and then go back and delete the mapping.
    I realize all this sounds crazy. But it was only an issue because you had not actually published the application. Not your fault, though, as this is a bug in APEX.
    This bug will be fixed in Application Express 4.0. This way, you won't have to worry about if you published or didn't publish. The orphaned rows will be cleaned up when you delete a mapping.
    Thanks again for reporting this.
    Joel

Maybe you are looking for

  • What is the correct way to transfer data from old hard drive to new Crucial SSD on a mid 2010 13" MBP

    I just bought an Crucial M550 256GB for my mid 2010 MBP. And I'm not clear on the data transfer instructions. 1) it came with Acronis instalation kit with a blank CD and a usb cable. I'm not sure what this CD is used for? 2) is it best to install the

  • Possible to color an entire page in Pages ?

    I would like to know if it is possible in Pages to have the entire page colored (not white) and still be  able to add text and photos on top of the colored page (much like one can in Keynote). I do short reports and I thought it might be nice to vary

  • Shopping cart Issues

    Hi Its SRM 3.0 implemented ( Classic scenario). Now the problem is when i create shopping cart with more than 1 line item and in one line item i choose item from (Dell Catalogue) and i order the cart then separate PO is getting created for line item

  • Junk Mail (Spam)

    Lately I've been receiving 3 or 4 mails a day with no address and no subject also no message, just the date received and time received. Please help me get rid of this and put it in the trash?

  • Radio streaming from Smart Headset Pro to Android phone

    Is there an Android app (or could I write one) that plays the radio stream from the Smart Headset Pro, e.g. using the phones speakers if the earplugs are not connected. Friedger