0 Replies Latest reply on Jun 10, 2008 3:17 AM by Mallikarjun SG

    throws javax.ejb.RemoveException,javax.ejb.EJBException, cau

    Mallikarjun SG Newbie

      Hi,

      I am getting the following error when trying to use composite primary key for deletion of a record.

      2008-06-10 12:29:36,176 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.RCVlanLoopDetectedTableHome] Executing SQL: SELECT rcVlanLoopDetectedVlanId, rcVlanLoopDetectedPortIndex, rcVlanLoopDetectedValue FROM rcVlanLoopDetectedTable WHERE ()
      2008-06-10 12:29:36,176 ERROR [org.jboss.ejb.plugins.LogInterceptor] EJBException in method: public abstract void javax.ejb.EJBLocalObject.remove() throws javax.ejb.RemoveException,javax.ejb.EJBException, causedBy:
      java.sql.SQLException: Syntax error or access violation, message from server: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1"


      The code that I have written is:

      primary key class

      public class RCVlanMacTablePK implements Serializable {
      
       Long rcVlanMacVlanId;
       String rcVlanMacAddr;
      
       public RCVlanMacTablePK() {
      
       this.rcVlanMacVlanId = null;
       this.rcVlanMacAddr = null;
      
       }
      
       public RCVlanMacTablePK(HashMap<String, Object> values) {
      
       this.rcVlanMacVlanId = Long.parseLong(values.get("rcVlanMacVlanId")
       .toString());
       this.rcVlanMacAddr = values.get("rcVlanMacAddr").toString();
      
       }
      }


      In the session facade calling delete method for deleting the record in a table:

       public String delete(HashMap<String, Object> values) {
      
       try {
       RCVlanMacTablePK pk = pkLoader(values);
       home.remove(pk);
       } catch (RemoveException e) {
       log.info("RCVlan: Exception in deleted method " + e);
       } catch (EJBException e) {
       log.info("RCVlan: Exception in deleted method " + e);
       } catch (NumberFormatException e) {
       log.info("RCVlan: Exception in deleted method " + e);
       }
       return str;
       }
      
      


      above pkLoader(values) is the method to load the primark key class and passing that primary key class variable to the remove method and calling remove(Object primarykey) method of EJBLocalHome Interface. ie home.remove(pk);

      In the ejb-jar.xml:

       <entity>
       <ejb-name>RCVlanMacTableHome</ejb-name>
       <local-home>com.sasken.sasems.server.beens.RCVlanMacTableHome</local-home>
       <local>com.sasken.sasems.server.beens.RCVlanMacTableRemote</local>
       <ejb-class>com.sasken.sasems.server.beens.RCVlanMacTableBean</ejb-class>
       <persistence-type>Container</persistence-type>
       <cmp-version>2.x</cmp-version>
       <abstract-schema-name>rcVlanMacTable</abstract-schema-name>
       <prim-key-class>com.sasken.sasems.server.beens.RCVlanMacTablePK</prim-key-class>
       <reentrant>False</reentrant>
       <cmp-field>
       <field-name>rcVlanMacVlanId</field-name>
       </cmp-field>
       <cmp-field>
       <field-name>rcVlanMacAddr</field-name>
       </cmp-field>
       <cmp-field>
       <field-name>rcVlanMacRowStatus</field-name>
       </cmp-field>
       </entity>
      


      I am getting the above error when executing the same. Please let me what needs to be done for a composite primary key.

      Thank you,
      Mallikarjun.