I've been reading the threads:
http://www.mail-archive.com/[email protected]/msg03894.html and
http://www.mail-archive.com/[email protected]/msg02858.html trying to
find a solution to the my cache problem.  I am still having troubles.
Here's my
problem. I have an Employee object that holds a collection of Tasks.  The
Task object holds a reference back to the Employee.  The mapping holds for
both the Java classes and database/mapping.  When I start my application,
the relationships are loaded fine.  But, when I create a new Task and
re-display the Employee, the task list is not updated with the new task. The
classes and the mapping actually duplicate the JDO example where the Product
holds a collection of ProductDetail and the ProductDetail holds a reference
back to the Product.  Here's my code and mapping.  

package sample.app.businessmodel;

import java.util.Vector;

import org.exolab.castor.jdo.TimeStampable;

/**
 * Employee
 */
public class Employee extends Person implements TimeStampable {

  private Position position;
  private Vector tasks = new Vector();
  private long timeStamp;

  /**
   * Employee constructor
   */
  public Employee() {}

  /**
   * @return Position
   */
  public Position getPosition() {
    return position;
  }

  /**
   * @return java.util.Vector
   */
  public Vector getTasks() {
      return tasks;
  }

  /**
   * @param Position newPosition
   */
  public void setPosition(Position newPosition) {
      position = newPosition;
  }

  /**
   * @param newTasks java.util.Vector
   */
  public void setTasks(Vector newTasks) {
      tasks = newTasks;
  }

  /**
   * @return long
   */
  public long jdoGetTimeStamp() { return timeStamp; }

  /**
   * @param long timeStamp
   */
  public void jdoSetTimeStamp(long timeStamp) {
    this.timeStamp = timeStamp;
  }

  /**
   * @return String
   */
  public String toString() {
    return "Employee: [" + super.toString() + "," + position + "," + tasks +
"]";
  }

}

package sample.app.businessmodel;

import org.exolab.castor.jdo.TimeStampable;

/**
 * Task
 */
public class Task implements TimeStampable {
  private String name = "";
  private Employee employee = null;
  private Integer id = null;
  private long timeStamp;

  /**
   * Task constructor
   */
  public Task() {}

  public Integer getId() { return id; }
  public void setId(Integer id) { this.id = id; }

  /**
   * @return Employee
   */
  public Employee getEmployee() {
      return employee;
  }

  /**
   * @param Employee
   */
  public void setEmployee(Employee newEmployee) {
      employee = newEmployee;
  }

  /**
   * @return java.lang.String
   */
  public String getName() {
      return name;
  }

  /**
   * @param newName java.lang.String
   */
  public void setName(String newName) {
      name = newName;
  }

  /**
   * @return long
   */
  public long jdoGetTimeStamp() { return timeStamp; }

  /**
   * @param long timeStamp
   */
  public void jdoSetTimeStamp(long timeStamp) {
    this.timeStamp = timeStamp;
  }

  /**
   * @return String
   */
  public String toString() {
    return "Task: [" + id + "," + name + "," + employee.getId() + "]";
  }
}

<!--  MXpping for Employee -->
  <class name="sample.Xpp.businessmodel.Employee"
         extends="sample.Xpp.businessmodel.Person" identity="id"
         key-generator="HIGH/LOW">
    <deXcription>Employee</deXcription>
    <map-to table="employee" />
    <field name="position" type="sample.Xpp.businessmodel.Position">
      <sql name="position_id" />
    </field>
    <field name="tasks" type="sample.Xpp.businessmodel.Task"
           collection="vector">
     <sql many-key="employee_id" />
    </field>
  </class>


  <!--  MXpping for Task -->
  <class name="sample.Xpp.businessmodel.Task" identity="id"
      key-generator="HIGH/LOW">
    <deXcription>Employee Task</deXcription>
    <map-to table="task" />
    <field name="id" type="integer">
      <sql name="id" type="integer"/>
    </field>
    <field name="name" type="string">
      <sql name="name" type="varchar"/>
    </field>
    <field name="employee" type="sample.Xpp.businessmodel.Employee">
      <sql name="employee_id" />
    </field>
  </class> 

Any ideas/help would be greatly appreciated.

Thanks,

Chris

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to