Try this 
It should work :)

import org.apache.ojb.broker.util.ProxyHelper;


...

ProxyHelper.getRealObject(iter.next());


B.R 

T.H


-----Original Message-----
From: Coup, Robert Muir [mailto:[EMAIL PROTECTED] 
Sent: Monday, February 02, 2004 4:27 AM
To: [EMAIL PROTECTED]
Subject: Forcing materialization of a dynamic proxy object


Hi all,

I have searched through the archives and can't seem to find any answer. How
can I force a proxy to materialize its object, or to replace the proxy
object witht the real object?

I have a collection of Group objects within a Paper object. Group's are
proxied dynamically (group, staffgroup), and can be of two types - groupimpl
or staffgroupimpl. Groupimpl is the parent of staffgroupimpl.

When the Paper objects collection arrives, it is a bunch of proxy objects.
In one operation, I must manipulate the staffgroups in the paper.groups
collection.

For (Iterator iter=groups.iterator; iter.hasNext;) {
        Group g = (Group)iter.next();
        if (g instanceof StaffGroup) {
                ...
        }
}

This fails because none of the objects are seen as StaffGroup's. Even
attempting to resolve them through a call to .getSomething() seems to leave
the objects as $Proxy2's....

Ideas?

Thanks,
Robert Coup



Classes:
        Interface Group
        Interface StaffGroup extends Group
        
        Class GroupImpl implements Group
        Class StaffGroupImpl extends GroupImpl implements StaffGroup

Repository:
    <class-descriptor class="Group">
        <extent-class class-ref="GroupImpl"/>
        <extent-class class-ref="StaffGroup"/>
    </class-descriptor>
    <class-descriptor class="GroupImpl" table="tGroup" proxy="dynamic">
        .... Fields ...
    </class-descriptor>

    <class-descriptor class="StaffGroup">
        <extent-class class-ref="StaffGroupImpl"/>
    </class-descriptor>
    <class-descriptor class="StaffGroupImpl" table="tGroup" proxy="dynamic">
        .... Fields ...
    </class-descriptor>

    <class-descriptor class="Paper" table="tPaper" proxy="dynamic">
        .... Fields ...
        <collection-descriptor 
            name="groups" 
            element-class-ref="Group"
            auto-retrieve="true"
            auto-update="false"
            >
                ...
        </collection-descriptor>
    </class-descriptor>

---------------------------------------------------------------------
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