0 Replies Latest reply on Apr 4, 2002 4:05 AM by Antonio

    problems with PrimaryKeyClass??

    Antonio Newbie

      I have this table in MySQL database:

      PK id Int
      nome Varchar

      I tryied two ways of coding:

      1 - with the PrimaryKey class so made

      public class KeyTestPK implements java.io.Serializable
      public Integer id;

      public KeyTestPK(Integer id)
      this.id = id;
      public KeyTestPK(){ }

      public int hashCode()
      return (id).hashCode();
      public boolean equals(Object obj)
      if (this.getClass().equals(obj.getClass()))
      KeyTestPK that = (KeyTestPK) obj;
      return this.id.equals(that.id);
      return false;

      I tryed also the same class with the toString method and getter and setter for id field.

      2 - without the above class

      I obtained that the case 2 does function well, while in the case 1 there is some problem.
      In detail this message is presented in the JBoss console when I try to execute the getNome method of the entity
      [09:33:15,989,CMP] Didn't read ahead field 'nome'
      The method returns the value I requested correctly.
      This situation became a problem when I try to do the same thing for a table with more than 2 columns in PK:
      the transaction is corrupted and this message is presented
      Read ahead failed
      followed by a lot of other messages ...

      How to avoid this behaviour?
      maybe the PrimaryKey class I had wrote is wrong?
      how can I disable the read-ahead feature?
      maybe there is something to set in the jbosscmp-jdbc.xml or in the ejb-jar.xml file???

      can anyone help me, please?

      Using: JBoss3.0alpha JDK1.4 EJB2.0 MySQL4.0.0-alpha-max-nt(INNODB type tables)