Hi all, i spent the whole weekend trying to adapt my project using OJB, here comes a 
list of questions i really can't figure out answers in the mailing list archive. i 
tested with these (w2k, jdk1.4.1, sun one studio, mysql, mm 2.0.14 jdbc driver)

public class User extends BusinessObject {
 private String userId; // aggregated
 private String password; // aggregated
 private Timestamp creationDatetime; // aggregated
 private Timestamp lastUpdateDatetime; // aggregated
 private String name; // aggregated
 private BusinessObjectList permissions; // aggregated
 private String statusType; // aggregated

...
}

public class UserPermission extends BusinessObject {
 private String name; // aggregated
 private String value; // aggregated
...
}

where BusinessObject is a super class of our business entity of the following 
definition

public abstract class BusinessObject implements Serializable, Cloneable {
 private String primaryKey; // not updateable, direct dirty
 private int sequenceNumber; // aggregated, direct dirty
 private BusinessObject owner; // not updateable, direct dirty
    private String ownerPrimaryKey;
...
}

mappings are done with these

   <class-descriptor class="hk.com.mydomain.domain.security.User" table="USER">
      <documentation>This is important documentation on the Article 
class.</documentation>
      <field-descriptor name="primaryKey" column="USER_UUID" jdbc-type="NUMERIC" 
primarykey="true" autoincrement="true" 
conversion="hk.com.mydomain.dao.util.StringBigDecimalConversion" />
      <field-descriptor name="userId" column="USER_ID" jdbc-type="VARCHAR" />
      <field-descriptor name="password" column="PASSWORD" jdbc-type="VARCHAR" />
      <field-descriptor name="creationDatetime" column="CRE_DT" jdbc-type="TIMESTAMP" 
/>
      <field-descriptor name="lastUpdateDatetime" column="LAST_UPD_DT" 
jdbc-type="TIMESTAMP" />
      <field-descriptor name="name" column="NAME" jdbc-type="VARCHAR" />
      <field-descriptor name="statusType" column="STATUS_TYPE" jdbc-type="CHAR" />
      <collection-descriptor name="permissions" 
element-class-ref="hk.com.mydomain.domain.security.UserPermission" 
auto-retrieve="true" auto-update="true" auto-delete="true">
         <orderby name="sequenceNumber"/>
         <inverse-foreignkey field-ref="ownerPrimaryKey" />
      </collection-descriptor>
   </class-descriptor>

   <class-descriptor class="hk.com.mydomain.domain.security.UserPermission" 
table="USER_PERMISSION">
      <documentation>This is important documentation on the Article 
class.</documentation>
      <field-descriptor name="primaryKey" column="USER_PERMISSION_UUID" 
jdbc-type="NUMERIC" primarykey="true" autoincrement="true" 
conversion="hk.com.mydomain.dao.util.StringBigDecimalConversion" />
      <field-descriptor name="ownerPrimaryKey" column="USER_UUID" jdbc-type="NUMERIC" 
/>
      <reference-descriptor name="owner" 
class-ref="hk.com.mydomain.domain.security.User">
         <foreignkey field-ref="ownerPrimaryKey" />
      </reference-descriptor>
      <field-descriptor name="name" column="NAME" jdbc-type="VARCHAR" />
      <field-descriptor name="value" column="VALUE" jdbc-type="VARCHAR" />
   </class-descriptor>



essentially, it's a 1-M (User-UserPermission) mapping, with back-reference from 
UserPermission to User implemented using owner association.

- first problem comes to me is my original BusinessObject class models primaryKey 
using BigDecimal, do i have  a way to keep it? i'm now using a self implemented 
StringBigDecimalConversion class to do the conversion job that i find too indirect and 
waste computation resource
- second question is when there is already owner association setup from UserPermission 
to User, why OJB requires us to have a dedicated 'back-attribute' ownerPrimaryKey or 
like this user 
http://archives.apache.org/eyebrowse/ReadMsg?[EMAIL PROTECTED]&msgId=463861
 is doing, having customerNo instead of customer object? this would introduce poor 
design and navigatability problem.
- tried write up a code fragment to persist a uesrA->(user permission 1, user 
permission 2) data structure, checked the backreferences 'owner' is set already, 
however when persisted, the foreign key relation dropped, first thing ran thru my mind 
is the ownerPrimaryKey that must have been missing when setting up the hierarchy. is 
there any way we can have the back reference setup automatically?
- i tried followed this 
http://archives.apache.org/eyebrowse/ReadMsg?[EMAIL PROTECTED]&msgId=500562
 and wanted to see if any sql's generated but in vain, anybody can help?
- did anybody ever try ojb persisting data of encoding other than iso8859-1? i tried 
to look for if any 'chinese' or 'japanese' in the mailing list and can't find any 
questions related to 'em.. 


Best Regards,

Jemmee Yung
My Domain Consultant Limited
http://my-domain.com.hk/

Reply via email to