Make IdAgents serializable. 


On Wed, 14 Mar 2001, Jean-Michel DELSAUX wrote:

> Hi all,
> 
> I have the next warning:
> 
>   [Verifier]
>   Bean   : IdAgentsBean
>   Method : public abstract IdAgents create(int, String, int) throws 
> RemoteException, CreateException, EJBException
>   Section: 9.2.8
>   Warning: The method return values in the home interface must be of valid 
> types for RMI/IIOP.
> 
>   [Verifier]
>   Bean   : IdAgentsBean
>   Method : public abstract IdAgents findByPrimaryKey(IdAgentsPK) throws 
> RemoteException, FinderException, EJBException
>   Section: 9.2.8
>   Warning: The method return values in the home interface must be of valid 
> types for RMI/IIOP.
> 
> And my code is:
> 
>   IdAgents create(int balRank,
>                   String name,
>                   int signed) throws EJBException, CreateException, 
> RemoteException;
> 
> ////////////////////////////
>   public IdAgentsPK ejbCreate(int balRank,
>                               String name,
>                               int signed) throws CreateException {
> /*    if((name.equals("")) || (balRank == 0))
>       throw new CreateException("Invalid Parameters");*/
> 
>     Date today = new Date(System.currentTimeMillis());
> 
>     this.m_BALRANK    = balRank;
>     this.m_NAME       = name;
>     this.m_DENCOD     = today.toString();//Today on yyyy-mm-dd format
>     this.m_ACT        = ACTIVE;
>     this.m_SIGNED     = signed;
> 
>     Connection con = null;
>     PreparedStatement ps = null;
>     IdAgentsPK primaryKey = null;
>     ResultSet rs = null;
>     try {
>       con = m_idCon.getConnection();
>       //Get the sequence id
>       ps = con.prepareStatement("SELECT seq_vagen.NEXTVAL as id FROM dual");
>       rs = ps.executeQuery();
>       if(!rs.next())
>         throw new ObjectNotFoundException("Cannot find a valid sequence 
> number in Agent Table");
> 
>       this.m_ID_AGEN = rs.getInt("id");
> 
>       ps = con.prepareStatement(
>              "INSERT INTO vagen (id_agen, balRank, name, dencod, act, 
> signed) " +
>              "VALUES(?,?,?,?,TO_DATE(?,'YYYY-MM-DD'),?,?)");
> 
>       ps.setInt(1, this.m_ID_AGEN);
>       ps.setInt(2, this.m_BALRANK);
>       ps.setString(3, this.m_NAME);
>       ps.setString(4, this.m_DENCOD);
>       ps.setString(5, this.m_ACT);
>       ps.setInt(6, this.m_SIGNED);
> 
>       //Execute the insert
>       if(ps.executeUpdate() != 1)
>         throw new CreateException("Failed to add Agents table");
> 
>       //Primary key
>       primaryKey = new IdAgentsPK(this.m_ID_AGEN);
>     } catch(SQLException se) {
>       if(DEBUG) System.out.println("ejbCreate ERROR: " + se.getMessage());
>       m_context.setRollbackOnly();
>       throw new EJBException("IdAgentsBean - ejbCreate Exception: " + 
> se.getMessage());
>     } finally {
>       try {
>         if(rs != null) rs.close();
>         if(ps != null) ps.close();
>         if(con != null) con.close();
>       } catch(SQLException se) {
>         if(DEBUG) se.printStackTrace();
>         throw new EJBException(se);
>       } finally {
>         return primaryKey;
>       }
>     }
>   }
> 
> //////////////////////
> 
>   public class IdAgentsPK implements java.io.Serializable {
> 
>     private int m_ID_AGEN;
> 
>     public IdAgentsPK() {
>     }
> 
>     public IdAgentsPK(int value) {
>       m_ID_AGEN = value;
>     }
> 
>     public int getPK() { return m_ID_AGEN; }
>     public void setPK(int i) { m_ID_AGEN = i; };
> 
>     public boolean equals(Object obj) {
>       if((obj == null)  || !(obj instanceof IdAgentsPK )) return false;
>       else if(((IdAgentsPK)obj).m_ID_AGEN == m_ID_AGEN) return true;
>       else return false;
>     }
> 
>     public int hashCode() {
>       return m_ID_AGEN;
>     }
> 
>     public String toString() {
>       return String.valueOf(m_ID_AGEN);
>     }
>   }
> 
> What's wrong with my code?
> 
> Thanks for your help.
> 
> JMi
> _________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
> 
> 
> 
> --
> --------------------------------------------------------------
> To subscribe:        [EMAIL PROTECTED]
> To unsubscribe:      [EMAIL PROTECTED]
> 

-- 
Dan Christopherson (danch) 
nVisia Technical Architect (www.nvisia.com)

Opinions expressed are mine and do not neccessarily reflect any 
position or opinion of nVISIA.

---------------------------------------------------------------------------
If you're a capitalist and you have the best goods and they're 
free, you don't have to proselytize, you just have to wait.
-Eben Moglen



--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]

Reply via email to