OK Craig,

So i have an array of proxis representing the beans on the app server. But 
how can i use them? If there are proxis, i could cast them to the remote 
interface and i could use all the methods declare by the remote interface 
for each proxis. Well let's try.

JMi


----Original Message Follows----
From: Craig Day <[EMAIL PROTECTED]>
>Hi, I have the next function (see below)
>
>It returns an Enumeration of IdSectorPK.  But we know that at the ckient 
>part,
>we have to cast.  the problem is that when i cast, i got an error:
>  java.lang.ClassCastException: $Proxy1
>
>Why can't i cast to IdSectorPK???????????????????
>
>Please help.


the ejbFindBySectorID method is (should be) declared as returning a 
Collection.
Transparently in the app server a call to findBySectorID on the home 
interface results in the ejbFindBySectorID method to be called, which 
retrieves the primary keys. The app server then uses those primary keys to 
create entity bean instances and load them up using ejbLoad. jBoss then 
returns to you an array of dynamic proxies representing the created beans on 
the server side.

cheers
craig


>JMi
>
>=========================
>client code
>===========
>  IdSectorHome home = (IdSectorHome) PortableRemoteObject.narrow (ref3,
>IdSectorHome.class);
>  Enumaration enum = home.findBySectorId("XX");
>  while(theEnum.hasMoreElements()) {
>    Object obj = theEnum.nextElement();
>    System.out.println(" ID: " + obj);
>    //System.out.println("  CLASS: " + obj.getClass());
>    IdSectorPK pro = (IdSectorPK) obj;//this line build an error
>                                       //java.lang.ClassCastException:
>$Proxy1 at client.main(client.java:143)
>  }
>
>
>
>=========================
>Server code
>===========
>Enumeration findBySectorId(String sectorId) throws RemoteException,
>FinderException;//Home interface
>
>public Enumeration ejbFindBySectorId(String sectorId) throws 
>FinderException {
>    Connection con = null;
>    PreparedStatement ps = null;
>    ResultSet rs = null;
>    Vector keys = new Vector();
>    try {
>      con = this.getConnection();
>      ps = con.prepareStatement(
>        "SELECT id_sect FROM vsect WHERE sector_id = ?");
>      ps.setString(1, sectorId);
>      //Execute the Query
>      rs = ps.executeQuery();
>      while(rs.next()) {
>        IdSectorPK sectorPk = new IdSectorPK(rs.getInt("ID_SECT"));
>        keys.addElement(sectorPk);
>      }
>    } catch(SQLException se) {
>      //throw new EJBException(se);
>    } finally {
>      try {
>        if(rs != null) rs.close();
>        if(ps != null) ps.close();
>        if(con != null) con.close();
>      } catch(SQLException se) {
>        se.printStackTrace();
>      } finally {
>        //Always return collection, even if empty
>        return keys.elements();
>      }
>    }
>  }
>_________________________________________________________________________
>Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
>
>
>--
>--------------------------------------------------------------
>To subscribe:        [EMAIL PROTECTED]
>To unsubscribe:      [EMAIL PROTECTED]
>List Help?:          [EMAIL PROTECTED]
>



--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
List Help?:          [EMAIL PROTECTED]


_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.



--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
List Help?:          [EMAIL PROTECTED]

Reply via email to