I'm trying to use Dynamic proxies, My tables are setup as such:
TableName (derived object for business rules), implements TableNameInterface
|
|-- TableNameCO ( derived object for collections to be placed in ) , implements TableNameCOInterface
|
|-- TableNameBO (base object - all table fields go here) , implements TableNameBOInterface
|
|-- BaseObject (super object - contains a custom toString that dynamically prints this object's contents)
TableNameInterface extends TableNameCOInterface TableNameCOInterface extends TableNameBOInterface
TableNameBOInterface includes all getColumn and setColumn definitions.
Now, I'm attempting to load an object by criteria,
<code>
Criteria crit = new Criteria();
crit.addEqualTo("username",u);
crit.addEqualTo("password",new MD5(p));
Query q = QueryFactory.newQuery(AclUser.class,crit);
AclUserInterface IUser=null;
try {
/* WORKS */
Object obj = broker.getObjectByQuery(q);
/* Throws ClassCastException */
IUser = (AclUserInterface) broker.getObjectByQuery(q);
} catch { .... }
</code>Now, if I do a System.out.println(obj), I get the full object record as it should be... complete with the collections (thanks to my toString() in BaseObject).
But the IUser conversion dies.
Am I just an idiot? I've been playing with this for 2 days and have no clue... any assistance would be appreciated. I think that there should be some sample code for this included in the Tutorial, as this is probably a feature that people will want to use.
===============================
Here are the appropriate snippets from my repository file (for table AclUser)
<class-descriptor
class="edu.iupui.cmg.labratj.om.AclUserCO"
proxy="dynamic"
>
<extent-class class-ref="edu.iupui.cmg.labratj.om.AclUser"/>
</class-descriptor>
<class-descriptor
class="edu.iupui.cmg.labratj.om.AclUserBO"
>
<extent-class class-ref="edu.iupui.cmg.labratj.om.AclUserCO"/>
</class-descriptor>
<class-descriptor
class="edu.iupui.cmg.labratj.om.AclUser"
proxy="dynamic"
table="acl_user"
>
<field-descriptor
name="id"
column="id"
jdbc-type="INTEGER"
primarykey="true"
nullable="false"
autoincrement="true"
>
</field-descriptor>
<field-descriptor
name="username"
column="username"
jdbc-type="VARCHAR"
nullable="false"
>
</field-descriptor>
<field-descriptor
name="password"
column="password"
jdbc-type="VARCHAR"
nullable="false"
>
</field-descriptor>
<field-descriptor
name="first"
column="first"
jdbc-type="VARCHAR"
nullable="false"
>
</field-descriptor>
<field-descriptor
name="last"
column="last"
jdbc-type="VARCHAR"
nullable="false"
>
</field-descriptor>
<field-descriptor
name="email"
column="email"
jdbc-type="VARCHAR"
nullable="false"
>
</field-descriptor>
</class-descriptor>On Thursday, June 12, 2003, at 02:18 PM, [EMAIL PROTECTED] wrote:
You have to create an interface and your class implement that interface.
And then you have to cast whith that interface.
IA tA = (A)tIter.next();
Vinicius Bomfim
-=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-= -=-=- Marcus Breese [EMAIL PROTECTED] IU School of Medicine [EMAIL PROTECTED] Dept. of Biochemistry and Molecular Biology Center for Medical Genomics / Grow Lab
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
