How to Work with Composite Primary Key

Hi All,
I'm working with Toplink JPA. Here I have A problem with inserting into database table which have composite Primary Key.
What I'm doing is, I have two tables. to maintain many to many relation between these two tables I created another intermediate table which consists of foreign Keys (reference) of above two tables.
Now these two foreign Keys in the Intermediate table made as composite Primary Keys.
When I'm trying to the data in the Intermediate table I'm getting the foreign Keys values are null..
could anyone suggest me how to work with composite Primary Keys
Thanks,
Satish

I have the same problem, I have 3 tables with a join table joining them all. I have created an intermediate table entity. When I go to create a an entry, it says that I cannot enter null into "ID". Here is the SQl toplink generates:
INSERT INTO Z_AUTH_USER_AUTHORIZATION (CONTEXT_ID, AUTHORIZATION_ID, USER_ID) VALUES (?, ?, ?)
bind => [null, null, null]
Here are the classes:
-----------------------Join Table-----------------------------------------------
@Entity()
@Table(name = "Z_AUTH_USER_AUTHORIZATION")
public class AuthUserAuthorization implements Serializable{
@EmbeddedId
private AuthUserAuthorizationPK compId;
// bi-directional many-to-one association to AuthAuthorization
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "AUTHORIZATION_ID", referencedColumnName = "ID", nullable = false, insertable = false, updatable = false)
private AuthAuthorization authAuthorization;
// bi-directional many-to-one association to AuthContext
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "CONTEXT_ID", referencedColumnName = "ID", nullable = false, insertable = false, updatable = false)
private AuthContext authContext;
// bi-directional many-to-one association to AuthUser
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "USER_ID", referencedColumnName = "ID", nullable = false, insertable = false, updatable = false)
private AuthUser authUser;
---------------------------------------User table--------------------------------------------------------------
@Entity()
@Table(name = "Z_AUTH_USER")
public class AuthUser implements Serializable, IUser{
@Id()
@SequenceGenerator(name = "AUTH_USER_ID_SEQ", sequenceName = "Z_AUTH_USER_ID_SEQ")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AUTH_USER_ID_SEQ")
@Column(name = "ID", unique = true, nullable = false, precision = 10)
private Integer id;
// bi-directional many-to-one association to AuthUserAuthorization
@OneToMany(mappedBy = "authUser", fetch = FetchType.EAGER)
private java.util.Set<AuthUserAuthorization> authUserAuthorizations;
-----------------------------------Context table-----------------------------------------------------------------
@Entity()
@Table(name = "Z_AUTH_CONTEXT")
public class AuthContext implements Serializable, IContext{
@Id()
@SequenceGenerator(name = "AUTH_CONTEXT_ID_SEQ", sequenceName = "Z_AUTH_CONTEXT_ID_SEQ")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AUTH_CONTEXT_ID_SEQ")
@Column(name = "ID", unique = true, nullable = false, precision = 8)
private Integer id;
// bi-directional many-to-one association to AuthUserAuthorization
@OneToMany(mappedBy = "authContext", fetch = FetchType.EAGER)
private java.util.Set<AuthUserAuthorization> authUserAuthorizations;
----------------------------Authorization table-------------------------------------------------
@Entity()
@Table(name = "Z_AUTH_AUTHORIZATION")
public class AuthAuthorization implements Serializable, IAuthorization{
@Id()
@SequenceGenerator(name = "AUTH_AUTHORIZATION_ID_SEQ", sequenceName = "Z_AUTH_AUTHORIZATION_ID_SEQ")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "AUTH_AUTHORIZATION_ID_SEQ")
@Column(name = "ID", unique = true, nullable = false, precision = 8)
private Integer id;
// bi-directional many-to-one association to AuthUserAuthorization
@OneToMany(mappedBy = "authAuthorization", fetch = FetchType.EAGER)
private java.util.Set<AuthUserAuthorization> authUserAuthorizations;
I have tried to create the new entity several ways. I have tried to create one with the default constructor then set this entity on each of the other entities, I have also tried to pass in the entities to the join entity and set them there, but this doesn't work. Any help would be very appreciated!
Thanks,
Bill

Similar Messages

  • 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

  • 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

  • OC4J 9.0.4 Deadlock: CMR with composite primary key

    Hi,
    I just encountered a Deadlock in a CMR/CMP application involving a session bean and two entity beans, one of which (Item) has a composite primary key, comprising a foreign key to the second entity bean. The exception is thrown after ejbPostCreate() completes succesfully and the new row is committed to the ITEM table. I have provided the trace (verbosity = 10) below. The EJB Dev Guide does not offer too much detail on Deadlock conditions, so any input and suggestions are most welcome.
    regards and thanks
    George
    javax.ejb.EJBException: Deadlock detected: thread 8 thread 8state
    = thread 8
    id = 8
    thread = RMICallHandler-5
    user = [JAZNUserAdaptor: user=jazn.com/admin]
    runAsUser = null
    waitingState = null
    waitingForState = thread 8
    waitingForResource = Item server.ItemPK@bdc9b3
    notified = false
    interruptMessage = null
    rmiHandler = com.evermind.server.rmi.RMICallHandler@97617
    cmtConnections = null
    cmtConnectionCount = 0
    inDataSourceSensitiveRegion = false
    applicationThread.httpHandler = null
    contextContainer = OrderSB EJBHome
    transaction = null
    is waiting for resource entity Item server.ItemPK@bdc9b3 held by thread 8 thread 8state
    = thread 8
    id = 8
    thread = RMICallHandler-5
    user = [JAZNUserAdaptor: user=jazn.com/admin]
    runAsUser = null
    waitingState = null
    waitingForState = thread 8
    waitingForResource = Item server.ItemPK@bdc9b3
    notified = false
    interruptMessage = null
    rmiHandler = com.evermind.server.rmi.RMICallHandler@97617
    cmtConnections = null
    cmtConnectionCount = 0
    inDataSourceSensitiveRegion = false
    applicationThread.httpHandler = null
    contextContainer = OrderSB EJBHome
    transaction = null
    at com.evermind.server.ejb.AbstractEJBObject.startCallLocal(AbstractEJBObject.java:110)
    at ItemLocal_EntityBeanWrapper18.setNomen(ItemLocal_EntityBeanWrapper18.java:1912)
    at server.OrderSBBean.addItems(OrderSBBean.java:380)
    at OrderSB_StatelessSessionBeanWrapper2.addItems(OrderSB_StatelessSessionBeanWrapper2.java:1983)
    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.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:124)
    at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:48)
    at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
    at java.lang.Thread.run(Thread.java:536)

    Hi,
    I just encountered a Deadlock in a CMR/CMP application involving a session bean and two entity beans, one of which (Item) has a composite primary key, comprising a foreign key to the second entity bean. The exception is thrown after ejbPostCreate() completes succesfully and the new row is committed to the ITEM table. I have provided the trace (verbosity = 10) below. The EJB Dev Guide does not offer too much detail on Deadlock conditions, so any input and suggestions are most welcome.
    regards and thanks
    George
    javax.ejb.EJBException: Deadlock detected: thread 8 thread 8state
    = thread 8
    id = 8
    thread = RMICallHandler-5
    user = [JAZNUserAdaptor: user=jazn.com/admin]
    runAsUser = null
    waitingState = null
    waitingForState = thread 8
    waitingForResource = Item server.ItemPK@bdc9b3
    notified = false
    interruptMessage = null
    rmiHandler = com.evermind.server.rmi.RMICallHandler@97617
    cmtConnections = null
    cmtConnectionCount = 0
    inDataSourceSensitiveRegion = false
    applicationThread.httpHandler = null
    contextContainer = OrderSB EJBHome
    transaction = null
    is waiting for resource entity Item server.ItemPK@bdc9b3 held by thread 8 thread 8state
    = thread 8
    id = 8
    thread = RMICallHandler-5
    user = [JAZNUserAdaptor: user=jazn.com/admin]
    runAsUser = null
    waitingState = null
    waitingForState = thread 8
    waitingForResource = Item server.ItemPK@bdc9b3
    notified = false
    interruptMessage = null
    rmiHandler = com.evermind.server.rmi.RMICallHandler@97617
    cmtConnections = null
    cmtConnectionCount = 0
    inDataSourceSensitiveRegion = false
    applicationThread.httpHandler = null
    contextContainer = OrderSB EJBHome
    transaction = null
    at com.evermind.server.ejb.AbstractEJBObject.startCallLocal(AbstractEJBObject.java:110)
    at ItemLocal_EntityBeanWrapper18.setNomen(ItemLocal_EntityBeanWrapper18.java:1912)
    at server.OrderSBBean.addItems(OrderSBBean.java:380)
    at OrderSB_StatelessSessionBeanWrapper2.addItems(OrderSB_StatelessSessionBeanWrapper2.java:1983)
    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.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:124)
    at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:48)
    at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
    at java.lang.Thread.run(Thread.java:536)

  • 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

  • How to define Composite primary key for a Table

    Hi ,
    I am basically more into Java Programming , with little bit knowledge on Oracle as DataBase .so please excuse for my silly doubts .
    Can anybody please tell me how to define a Composite Primary Key on a Table .
    Thanks in advance .
    Edited by: user672373773 on Sep 25, 2009 8:54 AM

    Here is an example right out of the Oracle documentation and the syntax for adding PK since you mention adding a composite PK.
    Example creating composite index
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_indexing.htm#sthref594
    Syntax for adding a PK (composite or not)
    alter table oooooooo.tttttttt
    add constraint tttttttt_PK
    primary key (sample_column2,
    sample_column1)
    using index
    tablespace IDXSPC
    pctfree 05
    initrans 04
    maxtrans 08
    storage (initial 16k
    next 16k
    maxextents 32
    pctincrease 0);
    -- dictionary management with restricted storage, change as desired.
    HTH -- Mark D Powell --

  • Composite Primary Key using  cmp

    How can an Entity Bean with Composite Primary Key using Container Managed Persistance (CMP) be Deployed using in WebLogic Server 8.1
    pls help me

    Your text is a bit confusing, but I think the answer is yes (it can be used).  However, it would help to see the DDL that you are using (or that you propose to use) to avoid any misunderstandings. And please be specific about whether you are referring
    to COLUMNS that are part of a primary key versus the primary key itself (whether it is composed of one column or multiple columns).
    Lastly, why not just try it and see.

  • Master Detail Forms with 2 composite primary keys - Is there a workaround?

    Hello All,
    I have been searching for a workaround to the maximum 2 part primary key restriction on the multi-row updates, and master-detail forms, and am hoping that someone can help me. I am using HTMLDB v2.0.0.00.49 with IE 6 against a 9.2 DB.
    I successfully implemented the workaround of Fred Stoopendaal's (see Updata PK on HTML DB ) and it works fine for single page multi-record updateable forms, but alas I haven't been able to extend it to master detail forms (I think it is something to do with Oracle not allowing the "returning" clause on views).
    Here is what I tried:
    two tables, one with a 2 part composite primary key, which is the master table, and a detail table with 3 part composite primary key -
    --------- BEGIN SQL ---------
    create table master_table
    ( master_col1 number
    , master_col2 number
    , master_col3 varchar2(30)
    , constraint master_pk primary key (master_col1,master_col2));
    create table detail_table
    (detail_col1 number
    ,detail_col2 number
    ,detail_col3 number
    ,detail_col4 varchar2(30)
    , constraint detail_pk primary key(detail_col1,detail_col2,detail_col3)
    , constraint master_detail_fk foreign key (detail_col1,detail_col2) references master_table(master_col1,master_col2));
    create or replace view v_master_table as
    select rowid mata_rowid,mata.*
    from master_table mata;
    create or replace view v_detail_table as
    select rowid deta_rowid,
    (select rowid from master_table mata where mata.master_col1 = deta.detail_col1 and mata.master_col2 = deta.detail_col2) deta_mata_rowid
    , deta.*
    from detail_table deta;
    create or replace trigger mata_ins_upd_trg
    instead of insert or update on v_master_table
    referencing new as new old as old
    for each row
    begin
    if inserting then
    insert into master_table (master_col1, master_col2, master_col3)
    values (:new.master_col1, :new.master_col2, :new.master_col3);
    end if;
    if updating then
    update master_table
    set master_col1 = :new.master_col1,
    master_col2 = :new.master_col2,
    master_col3 = :new.master_col3
    where rowid = :old.mata_rowid;
    end if;
    end;
    create or replace trigger deta_ins_upd_trg
    instead of insert or update on v_detail_table
    referencing new as new old as old
    for each row
    begin
    if inserting then
    insert into detail_table ( detail_col1, detail_col2, detail_col3, detail_col4)
    values (:new.detail_col1, :new.detail_col2, :new.detail_col3, :new.detail_col4);
    end if;
    if updating then
    update detail_table
    set detail_col1 = :new.detail_col1,
    detail_col2 = :new.detail_col2,
    detail_col3 = :new.detail_col3,
    detail_col4 = :new.detail_col4
    where rowid = :old.deta_rowid;
    end if;
    end;
    --------- END SQL ---------
    Then I created a master-detail form in Apex on the two views, using the mata_rowid and deta_rowid as primary keys, and mata_rowid=deta_mata_rowid as the link. I realise that using a function to fetch the master rowid within the detail view query is costly, but it was my intention to modify the record fetch queries to use the real FK columns once things were up and running.
    It seems to generate the pages ok, and I can insert/update master table records, but as soon as I modify records in the detail table things go a bit haywire. I can't find any documentation on how the inbuilt MRU/MRD logic works, so can't figure out the issue.
    Can anyone out there tell me what the problem is with the logic above, or if they have come up with a neat solution to this annoying limitation. I know that many will say that I should modify the data model to use surrogate primary keys, but many of the uses for HTMLDB are new interfaces for old schemas, so a workaround that doesn't involve wholesale data model changes would be preferable.
    Thanks in advance,
    Mike Cretan

    Hi, this is likely not the most elegant way...but perhaps the simplest -- and I didn't have much time to play.
    I used Wizard to create two separate Master Detail forms, each with a separate detail table. Thus I ended up with four pages:
    Page "A" - "Selector" page for Master (Report), with Edit link driving to Detail-1
    Page "B" - Editable Master/Detail-1 page (HTML / Report)
    Page "C" - "Selector" page for Master (Report), with Edit link driving to Detail-2
    Page "D" - Editable Master/Detail-2 page (HTML / Report)
    Then I selected the primary key column TWICE on the Report on Page A. Modified the second instance of this column to navigate to Page D (passing primary key) exactly the way the original instance of this column navigates to Page B. Then I deleted Page C.
    Since you can have only one Tabular Entry form per page, this seemed the best way to drive two separate detail tables from a common interface.

  • 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

  • Composite primary key as foreign key not working

    i want have two tables
    in one table i make a composite primary key
    and in the other table i refer one of the column of the composite key from the above table as foreign key in this table but this didn't work.
    eg:
    create table temp1
    ( name char2(10),
    ssn# number(10)
    address varchar2(10)
    constraint (cons_1)primary key(name,ssn#) );
    create table temp2
    ( name1 char2(10) references temp1(name),
    add varchar(20));
    this didn't work....can't create temp2 table it's giving error

    The following includes some corrections and some suggestions. Your original code had several problems: missing comma, invalid name, invalid data type, no unique key for the foreign key to reference. The following fixes all of those and adds some meaningful names for the constraints and formats it so that it is easier to read.
    CREATE TABLE temp1
      (name       VARCHAR2 (10),
       ssn#       NUMBER   (10),
       address    VARCHAR2 (10),
       CONSTRAINT temp1_name_ssn#_pk
                  PRIMARY KEY (name, ssn#),
       CONSTRAINT temp1_name_uk
                  UNIQUE (name))
    Table created.
    CREATE TABLE temp2
      (name1      VARCHAR2 (10),
       address    VARCHAR2 (20),
       CONSTRAINT temp2_name1_fk
                  FOREIGN KEY (name1)
                  REFERENCES temp1 (name))
    Table created.

  • How to get my Addon to work with the license key?

    Hi,
    Can someone tell me how to get the Addon to work with the license key?
    I've follow the steps as stated in this thread:
    [Re: SBO 2005 A - How do I get a Connection string from SAP B1.|Re: SBO 2005 A - How do I get a Connection string from SAP B1.]
    1) i've registered a BASIS key and get a 'BASISXXXXXX" string
    2) then i paste my BASIS key in "Solution" of Add-On Indentifier Generator and generate the  Add-On Indentifier Code
    3) then i paste the string to my source code
    which is the "XXX" of the sample code in that thread.
    static string AddonIdentifierString="XXX";
    int lRetCode=0;
    int errCode=0;
    string errMsg= string.Empty;
    string connectionStr ="";
    link = new SAPbouiCOM.SboGuiApiClass();
    connectionStr =Environment.GetCommandLineArgs().GetValue(1).ToString();
    link.AddonIdentifier=AddonIdentifierString;
    link.Connect(connectionStr);
    oApp = link.GetApplication(-1);
    vCompany = new SAPbobsCOM.CompanyClass();
    string cookie = vCompany.GetContextCookie();
    string conStr = oApp.Company.GetConnectionContext(cookie);
    vCompany.SetSboLoginContext(conStr);
    lRetCode = vCompany.Connect();
    4) then i add my add-on using manager role at Add-on admin
    5) then i can see my add-on there. it not suppose to be there since i've not installed any of my add-on license for my own add-on.
    what steps did i miss? Can someone please advise? Thanks
    ps : i'm coding in VB

    Hi,
    i think you have to change the license file attributing the number of licensing for your addon, then download it from https://websmp202.sap-ag.de/smb and then install it on SAP License manager, then I think you should give the license for your addon for individual users (example manager)
    I hope it helps.
    Best regards

  • How can we export the Primary key values (along with other data) from an Advantage database?

    One of our customers is moving from our application (which uses Advantage Database Server) to another application (which uses other database technology). They have asked us to help export their data, so that they can migrate it to another database system. So far, we have used the Advantage Data Architect (ARC32) "Export Table Structures as Code" functionality to generate SQL. We used the "Include existing data" option. The SQL contains the necessary code to recreate the tables and indexes. The customer's IT staff will alter the SQL statements as necessary for their new system.
    However, there is an issue with the Primary Keys in these table. The resulting INSERT statements use AutoInc as the type for the Primary Key in each Table. These INSERT statements contains "DEFAULT" for the value of each of these AutoInc fields. The customer would like to output an integer value for each of these Primary Key values in order to maintain referential integrity in their new system.
    So far, I have not found any feature of ARC32 that allows us to export the Primary Key values. We had been using an older version of ARC32, since our application does not use the latest version of ADS. I did download the latest version of ARC32 (11.10), but it does not appear to include any new functionality that would facilitate doing this sort of export.
    Can somebody tell me if there is such a feature in ARC32?
    Or, is there is another Advantage tool to facilitate what we are trying to accomplish?
    If there are no Advantage tools to provide such functionality, what else would you suggest?

    George,
      It sounds like the approach you are using is the correct one. This seems to be the cleanest solution to me especially since the customer is able to modify the generated SQL statements for their new system.
      In order to preserve the AutoInc values I would recommend altering the table and changing the field datatype from AutoInc to Integer. Then export the table as code which will export the actual values. After the tables have been created on the new system they can change the field datatype back to an AutoInc type if necessary.
    Regards,
    Chris Franz

  • How to Alter any table to make some fields Composite Primary Key

    I need to Alter Table to make some fields Composite Primary Key.
    Is it possible to do this ?
    Please give any example.
    Regards,
    AgrawalV

    Agrawal
    If you are looking for an example to create a composite primary key, here you are.
    sql> Alter Table myTable add constraint pk_myTable primary key(col1, col2, ...coln) ;
    where
    pk_myTable is the name of the primary key constraint,
    myTable is the name of the table that you want to create a constraint on and
    col1...coln are the column names in the table <myTable)

  • Composite Primary Key in M:N CMP Entity Bean Relationship

    Dear Sir/Madam,
         We are creating an Enterprise Application for our institute using EJB 2.0 specifiactions. In the course of developement, we are facing a problem in writing the CMP Entity Beans with EJB Relationships.
         We are having many to many relationship between two beans such that the primary key of one Entity Bean (let's call it A), serves as the foreign key of another Entity Bean (let's call it B). Further, this primary key of A as foreign key in B, participates in the composite key of B.
         The EJB Specifications require that the primary key field(s) of any bean (B, in our case) declared in the Primary Key class should be the subset of the 'cmp-field' declared in the deployment descriptor for that bean. As I said earlier, we have many to many relationship at play. Hence, we require to keep the foerign key in the 'cmr-field' in lieu of 'cmp-field'. In short, the component of primary key is in 'cmr-field' while, it is needed in both 'cmp-field' and 'cmr-field'. That's perfect from Database point of view but illogical from CMP Entity Bean's view.
         How can we write the deployment descriptor for such a CMP (BMP is working fine for above scenario) Entity Bean? Also, how can we write the Primary Key class? The problem is not just to find the solution, but find under the hood of EJB 2.0 specifications.
         Please help.

    I think you should realise that it would not be convenient to use CMP for everything. It is difficult to define complex relations using CMP. Mostly BMP os preferd since it gives the flexibility for the bean developer.
    Regards
    xH4x0r

  • Querying on the basis of some attribute of composite primary key

    Hello,
    I am looking for suggestion about querying just on the basis of one attribute of the composite primary key.
    TO exemplify,
    I have a 6 attributes example A1,A2,A3,A4,A5,A6.
    A1,A2 and A3 together, serve as composite primary key.Now,because of the need of the project,I want to do querying on the basis of any A1,A2 or A3.One way I could think of is to have secondary indices on each of A1,A2,A3.
    Can some one explain me roughly how to go about it?
    I am a new user of BerkeleyDB Java Edition,hence not sure what would be a good way to do it.I understand one way to do it,would be to keep A1,A2,A3 in the Key class and A1,A2,A3,A4,A5,A6 in the value class as well.Then create secondary indices on the A1,A2 and A3 individually.
    Can someone suggest a more efficient way?
    Thanks,
    Will appreciate any suggestions.
    Prateek

    Exactly as you said. Create secondary indices on each attribute you want to index off of. I don't use the Java interface, but what you pretty much need to do is form your secondary key like so:
    skey: pkey_individual_attribute
    skeysize: pkey_individual_attribute_sizeHow to do this is documented in the BDB Java API docs:
    For example:
        class MyKeyCreator implements SecondaryKeyCreator {
            public boolean createSecondaryKey(SecondaryDatabase secondary,
                                                DatabaseEntry key,
                                                DatabaseEntry data,
                                                DatabaseEntry result)
                throws DatabaseException {
                // DO HERE: Extract the secondary key from the primary key and
                // data, and set the secondary key into the result parameter.
                return true;
        SecondaryConfig secConfig = new SecondaryConfig();
        secConfig.setKeyCreator(new MyKeyCreator());
        // Now pass secConfig to Environment.openSecondaryDatabaseThe extractor function used to construct the secondary index is passed the primary key and primary data - therefore all the data is available to you with no need to duplicate the key within the data itself. While the standard example is to use some part of the primary data to form a secondary key - there's absolutely nothing against using only a part of the primary key to form a secondary key instead. The only thing you have to do is slice up said primary key and construct the "result" parameter to be a single attribute. The backend API already knows which composite key this secondary entry will be associated with and as such will implicitly form the data (or as you called it "value") section of the index (which will be the composite primary key passed to it).
    The primary key/data should consist of the composite A1,A2,A3 with only A4,A5,A6 as data.
    The secondary->get() call (within the Java API) takes a key and provides back the primary key and primary data (basically the same as the db->pget() call in the C API). Since you've already indexed individual attributes, based off of the composite key, into their own respective databases - you just query from one of your secondary indexes with whatever specific attribute as the key. You then use the filled in primary key and primary data to work off of.

Maybe you are looking for

  • Iphone icon dose not appear in ' My Computer' , but appears in Itunes.

    Could someone help me out. I am using the Windows XP platform. I have an Iphone 8GB (1st Gen), initially the 'Iphone' icon would appear in 'My Computer', but recently it has stopped appearing! I have tried changing USB slots, reinstalled the driver,

  • Pdf file causing archive utility to throw error

    I have a couple of pdf files which cannot be compressed without an error. Supposing that the nasty file is called foo.pdf. . In the Finder, right click on foo.pdf . Select Compress "foo.pdf" A file called foo.pdf.zip is created but an error pops up A

  • I cannot use Sync Feature in my computer

    I have created a account to sync my Firefox settings in my computer. But i didn't complete the whole process earlier. Now i am trying to use my account to sync. But i cannot create a sync key with my earlier account. And also i tried to create a new

  • German to english docum

    Hi all, I had to copy a lot of SAP code for one of the requirements. Now the comments in the code are in german. is there a way i could translate them into english without going line by line copying and pasting from google language conversion tool. i

  • Update firefox to 36.0 Yahoo toolbar only has mail Everything else gone 35.0 was OK How do I get back 35.0?

    Question above states it all. I reinstalled Yahoo toolbar. No help. I do have the Yahoo toolbar but all my customizing is gone on it. I can't right click on toolbar to add stuff. I made the mistake of updating to Fox 36 on three different computers.