Why do you think that the partner object should support OrganizationIF?  It's
perfectly reasonable that it does not, for some configurations of data/classes.
Furthermore, if you load it using dynamic proxies, you've said I want to treat
this as a PartnerIF  the fact that the real object behind the scenes might
implement a other interfaces is not relevant.

David


|---------+--------------------------->
|         |           Joerg Lensing   |
|         |           <[EMAIL PROTECTED]|
|         |           nsing.de>       |
|         |                           |
|         |           09/11/2003 09:02|
|         |           AM              |
|         |           Please respond  |
|         |           to "OJB Users   |
|         |           List"           |
|         |                           |
|---------+--------------------------->
  
>--------------------------------------------------------------------------------------------------------------------------------------------------------------|
  |                                                                                    
                                                                          |
  |        To:      OJB Users List <[EMAIL PROTECTED]>                                 
                                                                     |
  |        cc:                                                                         
                                                                          |
  |        Subject: dynamci Proxy: ClassCastException with Interfaces                  
                                                                          |
  |                                                                                    
                                                                          |
  
>--------------------------------------------------------------------------------------------------------------------------------------------------------------|



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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]







---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to