1 Reply Latest reply on Oct 23, 2008 2:00 AM by Prasanth Kumar Sahu

    Composite Primary Key In a single table

    Mallikarjun SG Newbie

      Hi,

      I have a multiple primary key columns in a single table. i want to use these composite primary keys for deletion of a record in a table. what is the way to code the same. I am using CMP Bean and version is EJB2.0

      Please help me out.

      Thank you,
      Mallikarjun.

        • 1. Re: Composite Primary Key In a single table
          Prasanth Kumar Sahu Newbie

          Hi,

          I have a table which is having composite primary key(id,name), Can anyone tell me how to provide composite primary key in ejb-jar.xml.

          For primary key we can give like this:--

          <?xml version="1.0" encoding="UTF-8"?>

          <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise
          JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

          <ejb-jar>
          <enterprise-beans>

          <ejb-name>ProductEJB</ejb-name>
          com.javasrc.licenseserver.ejb.product.ProductHomeRemote
          com.javasrc.licenseserver.ejb.product.ProductRemote
          <ejb-class>com.javasrc.licenseserver.ejb.product.ProductBean</ejb-class>
          <persistence-type>Container</persistence-type>
          <prim-key-class>java.lang.Integer</prim-key-class>
          <cmp-version>2.x</cmp-version>
          <abstract-schema-name>Product</abstract-schema-name>
          <cmp-field><field-name>id</field-name></cmp-field>
          <cmp-field><field-name>name</field-name></cmp-field>
          <primkey-field>id</primkey-field>
          <security-identity><use-caller-identity/></security-identity>

          </enterprise-beans>
          <assembly-descriptor>
          <container-transaction>

          <ejb-name>ProductEJB</ejb-name>
          <method-name>*</method-name>

          <trans-attribute>Required</trans-attribute>
          </container-transaction>
          </assembly-descriptor>
          </ejb-jar>

          pls provide me solution for entering composite primary key.