I'm new to OJB and have researched the mailing list and the information
on the website. I can read and write to individual tables using code
and repository [at bottom] like so:
Criteria crit = new Criteria();
crit.addEqualTo("userid", userid);
Query q = QueryFactory.newQuery(ApplicationUser.class, crit);
Collection results = broker.getCollectionByQuery(q);
I'm still not clear as to how to do the equivalent of the following sql
query and store the information in the MenuItem business object. I
tried to do something similar to the example in the FAQ for doing your
own SQL, but that doesn't seem to work for a join. Assistance would be
greatly appreciated.
Query:
SELECT DISTINCT b.id, b.description, b.link, a.privilege FROM
user_Privileges a LEFT JOIN menuItems b ON a.menuItemId = b.id WHERE
a.userid = ?
Object:
public class MenuItem
{
private int id;
private String description;
private String link;
private String privileges;
[getters / setters ]
}
Repository:
<class-descriptor class="menus.businessobjects.ApplicationUser"
table="user_table" >
<field-descriptor
name="appUserId"
column="userid"
jdbc-type="VARCHAR"
primarykey="TRUE"
autoincrement="false"
/>
<field-descriptor
name="appUserPwd"
column="user_password"
jdbc-type="VARCHAR"
primarykey="false"
autoincrement="false"
/>
<field-descriptor
name="lastUpdatedBy"
column="U_LAST_UPD_USERID"
jdbc-type="VARCHAR"
primarykey="false"
autoincrement="false"
/>
<field-descriptor
name="lastUpdateDate"
column="U_LAST_UPD_TS"
jdbc-type="VARCHAR"
primarykey="false"
autoincrement="false"
/>
</class-descriptor>
<class-descriptor class="menus.businessobjects.UserPrivileges"
table="user_privileges" >
<field-descriptor
name="userid"
column="userid"
jdbc-type="VARCHAR"
primarykey="TRUE"
autoincrement="false"
/>
<field-descriptor
name="menuitemid"
column="menuitemid"
jdbc-type="VARCHAR"
primarykey="false"
autoincrement="false"
/>
<field-descriptor
name="privilege"
column="privilege"
jdbc-type="VARCHAR"
primarykey="false"
autoincrement="false"
/>
</class-descriptor>
<class-descriptor class="menus.businessobjects.MenuItem"
table="menuitems" >
<field-descriptor
name="id"
column="id"
jdbc-type="int"
primarykey="TRUE"
autoincrement="false"
/>
<field-descriptor
name="description"
column="description"
jdbc-type="VARCHAR"
primarykey="false"
autoincrement="false"
/>
<field-descriptor
name="link"
column="link"
jdbc-type="VARCHAR"
primarykey="false"
autoincrement="false"
/>
</class-descriptor>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]