Hi,
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Thursday, June 12, 2003 8:51 AM
> To: OJB Users List
> Subject: Problem of dynamic proxy?
>
>
> Hi!
> I declare a class-descriptor of A. Its proxy property is
> set dynamic. I try to load it from DB by oql command. The
> return collection is DList(because the
> OqlCollectionClass=org.apache.ojb.odmg.collections.DListImpl
> is set in OJB.properties), but the elements in DList are
> proxy objects not A.
The elements are proxies because you told OJB to use dynamic Proxies!
If you set proxy="dynamic" on the class-descriptor level it is activated for
all usages of class A. So also for OQL queries!
> How can I get A from DList except that I
> must not set A proxy property dynamic?
The only way is not to set proxy="dynamic".
it is possible to change the proxy setting at runtime. So you can deactivate
it for performing the query and activate it later.
> A class descript:
> <class-descriptor class="A" table="A" proxy="dynamic">
> :
> :
> :
> </class-descriptor>
>
> oql command : "select o from A"
>
> Using ODMG:
>
> 1 String pQueryString = "select o from A";
> 2 DList tResult = null;
> 3 try {
> 4 Transaction tx = this.odmg.currentTransaction();
> 5 OQLQuery tQuery = this.odmg.newOQLQuery();
> 6 tQuery.create(pQueryString);
> 7 tResult = (DList)tQuery.execute();
> 8 } catch (Exception e) {
> 9 e.printStackTrace();
> 10 throw new DBServerException(e.getMessage());
> 11 }
> 12 Iterator tIter = tResult.iterator();
> 13 while (tIter.hasNext()){
> 14 �� tA = (A)tIter.next();
> :
> :
> }
>
> I got a error message :"java.lang.ClassCastException:
> $Proxy119" on line 14.
A must be an Intreface type to be used with dynamic proxies !
cheers,
Thomas
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]