Menu

#2 Relations between object not saved

open
5
2014-08-18
2003-09-29
No

I have Department and Manager classes with many-to-
many relationship.
Department has a Set of Managers.
Manager has a Set of Departments.

Working with Castor : OK. I create my Managers and my
Departments then add Managers to Departments. When
I load a Manager, I get its Departments.

With phantom :

1.
Manager m1 = new Manager(...);
Department d1 = new Department(...);

m1.addDepartment(d1); // add d1 to the set in m1

jdoWorker.create(m1);

2.
Manager m1 = new Manager(...);
Department d1 = new Department(...);

m1.addDepartment(d1);

jdoWorker.create(d1);
jdoWorker.create(m1);

3.
Manager m1 = new Manager(...);
Department d1 = new Department(...);

jdoWorker.create(d1);

m1.addDepartment(d1);

jdoWorker.create(m1);

4.
Manager m1 = new Manager(...);
Department d1 = new Department(...);

jdoWorker.create(m1);
jdoWorker.create(d1);

m1.addDepartment(d1);

jdoWorker.update(m1);

In all cases, I get no error messages but the relation is
never found in the database. I load m1 and he has no
department.

Discussion

  • Alexey Efimov

    Alexey Efimov - 2003-10-02
    • assigned_to: nobody --> aefimov
     
  • Alexey Efimov

    Alexey Efimov - 2003-10-02

    Logged In: YES
    user_id=550350

    Hello,
    The frame work now not process collectional fields. It planed,
    but it hard to implement. I think about it.

    But follow code must work fine:
    Manager m1 = new Manager(...);
    Department d1 = new Department(...);

    jdoWorker.create(m1);
    jdoWorker.create(d1);

    m1.addDepartment(d1);

    jdoWorker.update(d1);

    Sure, i'll must have a valid addDepartment method:

    public class Manager {
    public void addDepartment(Department d) {
    if (!departmints.contains(d)) {
    department.add(d);
    d.setManager(this);
    }
    }
    }

    public class Department {
    public setManager(Manager m) {
    this.manager = m;
    m.addDepartment(this);
    }
    }

    Thanks!
    PS.
    Lets move to mailing list to discussion:
    http://lists.sourceforge.net/lists/listinfo/phantom-castor-
    development

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.