Hi again Kelvin,
I created this thread a long time ago and you answered me that SDO does not
support MxN relatioships between objects. The code above removes the first
department from the first company and adds it to the second company. I
expected that the reference the first company had to that department would
be removed automatically, but it's not being:
...
commonj::sdo::DataObjectPtr company1 = root->getDataObject("company[1]");
commonj::sdo::DataObjectPtr company2 = root->getDataObject("company[2]");
company1->printSelf(cout);
company2->printSelf(cout);
commonj::sdo::DataObjectPtr department =
company1->getDataObject("department[1]");
company2->getList("department").append(department);
company1->printSelf(cout);
company2->printSelf(cout);
...
Output:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> start of DO
DataObject type: apache.das#company
Property: id
Property Type: commonj.sdo#Int
Property Value: 1
Property: name
Property Type: commonj.sdo#String
Property Value: apache
Property: department
Property Type: apache.das#department
Value 0
Reference Value: #/department.0
Value 1
Reference Value: #/department.1
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end of do
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> start of DO
DataObject type: apache.das#company
Property: id
Property Type: commonj.sdo#Int
Property Value: 2
Property: name
Property Type: commonj.sdo#String
Property Value: acme
Property: department
Property Type: apache.das#department
Value 0
Reference Value: #/department.2
Value 1
Reference Value: #/department.3
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end of do
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> start of DO
DataObject type: apache.das#company
Property: id
Property Type: commonj.sdo#Int
Property Value: 1
Property: name
Property Type: commonj.sdo#String
Property Value: apache
Property: department
Property Type: apache.das#department
Value 0
Reference Value: #/department.0
Value 1
Reference Value: #/department.1
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end of do
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> start of DO
DataObject type: apache.das#company
Property: id
Property Type: commonj.sdo#Int
Property Value: 2
Property: name
Property Type: commonj.sdo#String
Property Value: acme
Property: department
Property Type: apache.das#department
Value 0
Reference Value: #/department.2
Value 1
Reference Value: #/department.3
Value 2
Reference Value: #/department.0
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end of do
So, as the output shows, the department.0 is added on the company2, but the
reference to department.0 that company1 has is not removed. Should it work
like this?
Regards,
Adriano Crestani
On 4/27/07, Adriano Crestani <[EMAIL PROTECTED]> wrote:
>
> Thanks Kevin : )
>
> Adriano Crestani
>
> On 4/27/07, Kevin Williams <[EMAIL PROTECTED]> wrote:
> >
> > There is no way to morph a 1:m relationship into a M:M
> > relationship. SDO
> > maintains referential integrity. If you have a dept1 with emp1 and then
> > execute:
> >
> > dep2.getEmployees.add(emp1)
> >
> > the graph will automagically remove emp1 from dep1's list of employees
> > and
> > you are left with valid 1:m relationships.
> >
> > --Kevin
> >
> >
> > On 4/27/07, Adriano Crestani < [EMAIL PROTECTED]> wrote:
> > >
> > > As described on
> > > http://wiki.apache.org/ws/ForeignKeyRepresentationAndManagement if a
> > table
> > > EMPLOYEE has a FK to a table DEPARTMENT it's mapped on the sdo graph
> > as
> > > the
> > > DEPARTMENT containing a list of EMPLOYEEs, So it's a 1xN relationship.
> > > However, if the sdo graph, after being created and populated, is
> > modified
> > > and two different DEPARTMENT DataObjects reference the same EMPLOYEE
> > > DataObject the relationship turns to NxN.
> > >
> > > How does the Java DAS handle that? Does it throw an exception?
> > >
> > > Adriano Crestani
> > >
> >
>
>