2 Replies Latest reply on Jul 3, 2002 5:31 PM by jawwad

    simple compund primary key program but horrable exception

    jawwad Newbie

      Well i am making simple compond primary key but it does not deploy the code is right i don't know where is mistake.I tried a lot.

      20:15:22,709 INFO [CustomerEJB] Created table 'CUSTOMEREJB' successfully.
      20:15:22,860 ERROR [EjbModule] Starting failed
      org.jboss.deployment.DeploymentException: Error while creating table; - nested throwa
      ble: (java.sql.SQLException: Column not found: ) in statement [CREATE TABLE ORDEREJB
      (userID VARCHAR(256), orderEvent VARCHAR(256), CustomerEJB_orderNumbers VARCHAR(256),
      CONSTRAINT PK_ORDEREJB PRIMARY KEY ())])
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStartCommand.createTable(JDBCStartComma
      nd.java:190)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStartCommand.execute(JDBCStartCommand.j
      ava:84)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.start(JDBCStoreManager.jav
      //////////////////////////////////////////////////////////

      The ejb.jar exml is
      /////////////////////////////////////////////////////
      <?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>
      <!--CUSTOMER EJB-->

      <ejb-name>CustomerEJB</ejb-name>
      com.ssuet.customer.Customer
      com.ssuet.customer.CustomerHome
      <ejb-class>com.ssuet.customer.CustomerBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>java.lang.String</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>Customer</abstract-schema-name>

      <cmp-field>
      <field-name>firstName</field-name>
      </cmp-field>

      <cmp-field>
      <field-name>lastName</field-name>
      </cmp-field>

      <cmp-field>
      <field-name>userID</field-name>
      </cmp-field>

      <cmp-field>
      <field-name>userPwd</field-name>
      </cmp-field>

      <cmp-field>
      <field-name>emailAddress</field-name>
      </cmp-field>


      <primkey-field>userID</primkey-field>




      <ejb-local-ref>
      <ejb-ref-name>ejb/OrderHomeLocal</ejb-ref-name>
      <ejb-ref-type>Entity</ejb-ref-type>
      <local-home>com.ssuet.order.OrderHomeLocal</local-home>
      com.ssuet.order.OrderLocal
      <ejb-link>OrderEJB</ejb-link>
      </ejb-local-ref>




      <ejb-name>OrderEJB</ejb-name>
      com.ssuet.order.OrderLocal
      <local-home>com.ssuet.order.OrderHomeLocal</local-home>
      <ejb-class>com.ssuet.order.OrderBean</ejb-class>
      <persistence-type>Container</persistence-type>
      <prim-key-class>com.ssuet.order.OrderPK</prim-key-class>
      False
      <cmp-version>2.x</cmp-version>
      <abstract-schema-name>Order</abstract-schema-name>

      <cmp-field>
      <field-name>userID</field-name>
      </cmp-field>


      <cmp-field>
      <field-name>orderEvent</field-name>
      </cmp-field>





      </enterprise-beans>

      <ejb-relation>
      <ejb-relation-name>Customer-Order</ejb-relation-name>

      <!--defining relation ship of customer-->
      <ejb-relationship-role>
      <ejb-relationship-role-name>Customer-has-many-Order-numbers</ejb-relationship-role-name>
      One
      <relationship-role-source>
      <ejb-name>CustomerEJB</ejb-name>
      </relationship-role-source>
      <cmr-field>
      <cmr-field-name>orderNumbers</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>
      <!--defining relationship of phone-->
      <ejb-relationship-role>
      <ejb-relationship-role-name>Order-belongs-to-Customer</ejb-relationship-role-name>
      Many
      <relationship-role-source>
      <ejb-name>OrderEJB</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>
      </ejb-relation>

      </ejb-jar>
      ///////////////////////////////////////////////////////////
      The OrderPK is as follows..........
      package com.ssuet.order;

      public class OrderPK implements java.io.Serializable{
      public String orderevent;
      public String userid;
      public OrderPK(){

      }
      public OrderPK(String orderevent,String userid){
      this.orderevent=orderevent;
      this.userid=userid;
      }

      public String getOrderEvent(){
      return this.orderevent;
      }

      public String getUserID(){
      return this.userid;
      }

      public boolean equals(Object obj){

      if((obj==null)||!(obj instanceof com.ssuet.order.OrderPK))
      return false;

      OrderPK orderkey=(OrderPK)obj;

      if((this.userid.equals(orderkey.userid))&&(this.orderevent.equals(orderkey.orderevent)))
      return true;
      else
      return false;

      }


      public int hashCode(){
      return this.userid.hashCode()^this.orderevent.hashCode();
      }

      public String toString(){
      return this.userid+" "+this.orderevent;
      }
      }

      //////////////////////////////////////////////////////
      CUSTOMER.JAVA
      package com.ssuet.customer;
      import javax.ejb.*;
      import java.rmi.*;

      public interface Customer extends javax.ejb.EJBObject
      {
      abstract public String getUserID()throws java.rmi.RemoteException;

      abstract public void setName(NameDO name)throws java.rmi.RemoteException;
      abstract public NameDO getName()throws java.rmi.RemoteException;

      abstract public void setUserPwd(String userpwd)throws java.rmi.RemoteException;
      abstract public String getUserPwd()throws java.rmi.RemoteException;

      abstract public void setEmailAddress(String emailaddress)throws java.rmi.RemoteException;
      abstract public String getEmailAddress()throws java.rmi.RemoteException;

      }
      /////////////////////////////////////////////////////
      CUSTOMERBEAN.JAVA
      //////////////////////////////////////////////////
      package com.ssuet.customer;
      import java.rmi.*;
      import javax.ejb.*;
      import javax.rmi.*;
      import javax.naming.*;
      import com.ssuet.order.*;
      import java.util.Collection;

      public abstract class CustomerBean implements javax.ejb.EntityBean{

      public String ejbCreateByUserID(String userid){
      setUserID(userid);
      return null;
      }
      public void ejbPostCreateByUserID(String userid){

      }

      public String ejbCreateByUserIDAndPwd(String userid,String pwd){
      setUserID(userid);

      return null;
      }

      public void ejbPostCreateByUserIDAndPwd(String userid,String pwd){
      setUserPwd(pwd);
      }


      public String ejbCreateByUserInfo(String userid,String pwd,NameDO name,String email){
      setUserID(userid);

      return null;

      }

      public void ejbPostCreateByUserInfo(String userid,String pwd,NameDO name,String email){
      setUserPwd(pwd);
      setName(name);
      setEmailAddress(email);
      }
      public void setName(NameDO name){

      }
      public NameDO getName(){
      return null;

      }



      abstract public void setFirstName(String fname);
      abstract public String getFirstName();

      abstract public void setLastName(String lname);
      abstract public String getLastName();

      abstract public void setUserID(String userid);
      abstract public String getUserID();

      abstract public void setUserPwd(String userpwd);
      abstract public String getUserPwd();

      abstract public void setEmailAddress(String emailaddress);
      abstract public String getEmailAddress();


      abstract public void setOrderNumbers(java.util.Collection orders);
      abstract public java.util.Collection getOrderNumbers();

      }

      ////////////////////////////////////////////////////////
      CUSTOMERHOME.JAVA
      ////////////////////////////////////////////////////////
      package com.ssuet.customer;
      import javax.ejb.*;
      import java.rmi.*;


      public interface CustomerHome extends EJBHome
      {

      public Customer createByUserID(String userid)throws CreateException,RemoteException;
      public Customer createByUserIDAndPwd(String userid,String pwd)throws CreateException,RemoteException;
      public Customer createByUserInfo(String userid,String pwd,NameDO name,String email)throws CreateException,RemoteException;
      public Customer findByPrimaryKey(String userid)throws javax.ejb.FinderException;

      }

      ///////////////////////////////////////////////////////
      ORDERHOMELOCAL.JAVA
      package com.ssuet.order ;
      import javax.ejb.*;

      public interface OrderHomeLocal extends javax.ejb.EJBLocalHome{

      public OrderLocal create(String orderevent,String userid);
      public OrderLocal findByPrimaryKey(OrderPK orderkey);

      }
      //////////////////////////////////////////////////////////
      ORDERBEN.JAVA
      ////////////////////////////////////////////////////
      package com.ssuet.order;
      import javax.ejb.*;
      import javax.naming.*;

      import javax.rmi.PortableRemoteObject;

      public abstract class OrderBean implements javax.ejb.EntityBean{

      public OrderPK ejbCreate(String orderevent,String userid){
      setOrderEvent(orderevent);
      setUserID(userid);
      return null;
      }
      public void ejbPostCreate(String orderevent,String userid){

      }

      abstract public void setUserID(String userid);
      abstract public String getUserID();

      abstract public void setOrderEvent(String date);
      abstract public String getOrderEvent();

      }
      ////////////////////////////////////////////////////////
      ORDERLOCAL.JAVA
      /////////////////////////////////////////////////////
      package com.ssuet.order;
      import javax.ejb.*;

      public interface OrderLocal extends javax.ejb.EJBLocalObject{

      public String getUserID();
      public String getOrderEvent();


      }

      Can any body tell where is mistake please will be very thankful.