I'm using two classes/tables in a 1:n reference with PerstistenceBroker
API. In the first table I have the machines and in the second one the
currently logged on persons. In the EMPLOYEES table I'm using a PK of
two columns (PERSONALID / MACHINEID). I'm not using ID. When a person
logs off, it is not deleted from EMPLOYEES table when using .store(obj).
The object contains the reduced collection of employees. If the machine
is removed, then all looged on persons are removed, too. So my
workaround is first .delete(oldObj), second .store(newObj) in a
transaction.
 
I'd rather use only store(newObj). But how to get it working?
 
Class/collection descriptors look like this:
 
   <class-descriptor
      class="com.aaa.bbb.ccc.ddd.Machine"
      table="MACHINE"
   >

  // some field descriptors....
 
   <collection-descriptor
      name="employees"
      element-class-ref="com.aaa.bbb.ccc.ddd.Employee"
      auto-retrieve="true"
      auto-update="true"
      auto-delete="true"
  orderby="personalid"
  sort="ASC"
    >
  <inverse-foreignkey field-ref="deviceID" />
     </collection-descriptor>
   </class-descriptor>

 
   <class-descriptor
      class="com.aaa.bbb.ccc.ddd.Employee"
      table="EMPLOYEE"
   >
 
      <field-descriptor
         name="familyName"
         column="FAMILYNAME"
         jdbc-type="VARCHAR"
         primarykey="false"
         autoincrement="false"
      />
 
     <field-descriptor
         name="firstName"
         column="FIRSTNAME"
         jdbc-type="VARCHAR"
         primarykey="false"
         autoincrement="false"
      />
     
     <field-descriptor
         name="personalID"
         column="PERSONALID"
         jdbc-type="VARCHAR"
         primarykey="true"
         autoincrement="false"
      />
     
     <field-descriptor
         name="roles"
         column="ROLES"
         jdbc-type="VARCHAR"
         primarykey="false"
         autoincrement="false"
      />
 
     <field-descriptor
         name="deviceID"
         column="DEVICEID"
         jdbc-type="VARCHAR"
         primarykey="true"
         autoincrement="false"
      />
 
   </class-descriptor>
 
 
Cheers,
Frank
 

Reply via email to