You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Joerg Lensing <in...@softcon-lensing.de> on 2003/09/11 12:57:07 UTC

Proxy: ClassCastException with casting interface

Hi all,
I have problems with casting interfaces (a $Proxy).
The classes are:
AbstractPersistentIF
|_PartnerIF
...|_OrganisationIF
...|_PersonIF

this is OK:     (PartnerIF)AbstractPersistentIF
      this too   (PersonIF)AbstractPersistentIF
   
this causes ClassCastException: (OrganisationIF)AbstractPersistentIF


any hints / solutions?

tx Joerg
         




---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


dynamci Proxy: ClassCastException with Interfaces

Posted by Joerg Lensing <in...@softcon-lensing.de>.
hi all,

I'm using dynamic proxies for these classes

look at this Interface/class-hierarchy:

AbstractPersistentIF
    |_PartnerIF
        |_OrganisationIF
        |_PersonIF

(PO: persistent/mapped objects)
AbstractPersistentPO
    |_PartnerPO
        |_OrganisationPO
        |_PersonPO

if i   query an organisation:
---- snip--------
    public PartnerIF getPartnerByOID(int pOID,Transaction tx) {

        // obtain a broker instance from the current transaction
        HasBroker hasBroker = (HasBroker) tx;
        PersistenceBroker broker = hasBroker.getBroker();
        Criteria crit = new Criteria();

        crit.addEqualTo("id", new Integer(pOID));

        Query query = new QueryByCriteria(PartnerPO.class, crit);

        PartnerIF partner = (PartnerIF)broker.getObjectByQuery(query);

        if (broker.hasClassDescriptor(partner.getClass())) {

            tx.lock(partner, org.odmg.Transaction.READ);
        }
        return partner;
    }
----snip

if i test the implemented interfaces for the queried class
(-->partner.getClass().getIntefaces();), it doesn't show the right
implemented interface. The class shoud show OrganisationIF, but shows
PersonIF as being implemented by this class

who can help?

tx joerg







---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org