db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jakob Braeuchi <jbraeu...@gmx.ch>
Subject Re: MtoN-Testcases fail
Date Sun, 04 Jan 2004 11:49:50 GMT
hi armin,

testInsertWithIndirectionTable_3 fails because there's no project with 
id = 4 , it has been deleted by a previous testcase.

jakob

Jakob Braeuchi wrote:

> hi armin,
> 
> 
> this is the code that works:
> 
>         // create new project
>         Project project = new Project();
>         project.setTitle(title);
> 
>         // create two persons and assign project
>         // and assign persons with project
>         Person p1 = new Person();
>         p1.setFirstname(title);
>         broker.store(p1);
> 
>         List projects_1 = new ArrayList();
>         projects_1.add(project);
>         p1.setProjects(projects_1);
> 
>         Person p2 = new Person();
>         p2.setFirstname(title);
>         broker.store(p2);
> 
>         List projects_2 = new ArrayList();
>         projects_2.add(project);
>         p2.setProjects(projects_2);
> 
>         ArrayList persons = new ArrayList();
>         persons.add(p1);
>         persons.add(p2);
>         project.setPersons(persons);
> 
>         broker.beginTransaction();
>         broker.store(p1);
>         broker.store(p2);
>         broker.commitTransaction();
> 
> 
> the perspn-project relationship is critical, it needs to be set 
> bidirectionaly. the problem is then that the referenced person must 
> alreay exist in the db or we'll get an integrity violation !
> 
> 
> jakob
> 
> Armin Waibel wrote:
> 
>> Hi Jakob,
>>
>> hmm, I don't know how to change this behaviour - you are the expert ;-)
>>
>> Please correct me if I misunderstood you. I modified/add 
>> testInsertWithIndirectionTable tests:
>>
>> testInsertWithIndirectionTable_1:
>> Add two new persons and one new project. Assign persons with the
>> new project.
>>
>> testInsertWithIndirectionTable_2:
>> Add two new persons and one new project. Assign persons to
>> project and vice versa.
>>
>> testInsertWithIndirectionTable_3:
>> Add two new persons to existing project
>>
>> testInsertWithIndirectionTable_4:
>> Add two new persons to existing project and vice versa
>>
>> None of these tests pass!! If it's not a bug, what do I wrong.
>> How do I create a new Project with two new Persons in one step?
>> How do I add two new Persons to an existing Project in one step?
>>
>> regards,
>> Armin
>>
>>
>> Jakob Braeuchi wrote:
>>
>>> hi armin,
>>>
>>> ojb creates the role on inserting the project. on inserting the person
>>>
>>> storing project:
>>> 1.) INSERT INTO PROJECT (ID,TITLE,DESCRIPTION) VALUES 
>>> ('10','testInsertAndDelete_21073135938250','')
>>>
>>> storing person 1:
>>> 2.) INSERT INTO PERSON (ID,FIRSTNAME,LASTNAME) VALUES 
>>> ('11','testInsertAndDelete_21073135938250','')
>>> 3.) DELETE FROM PERSON_PROJECT WHERE PROJECT_ID='10'
>>> 4.) INSERT INTO PERSON_PROJECT (PERSON_ID,PROJECT_ID) VALUES ('11','10')
>>>
>>> storing person 2:
>>> 5.) INSERT INTO PERSON (ID,FIRSTNAME,LASTNAME) VALUES 
>>> ('12','testInsertAndDelete_21073136478468','')
>>> 6.) DELETE FROM PERSON_PROJECT WHERE PROJECT_ID='10'
>>> 7.) INSERT INTO PERSON_PROJECT (PERSON_ID,PROJECT_ID) VALUES ('12','10')
>>>
>>> as you can see the m:n implementors for the project are always 
>>> deleted because the project is not associated with a person. this 
>>> happens in the recursion store(), storeCollections(), store() when 
>>> the person is stored.
>>>
>>> if (cds.isMtoNRelation())
>>> {
>>>   if (cds.getCascadeStore())
>>>   {
>>>    (steps 3 and 6)
>>>    store(otherObj);
>>>    currentMtoNKeys = mtoNBroker.getMtoNImplementor(cds, obj);
>>>   }
>>>   (steps 4 and 7)
>>>   mtoNBroker.storeMtoNImplementor(cds, obj, otherObj, 
>>> currentMtoNKeys); }
>>>
>>> i recently inserted the line currentMtoNKeys = ... after 
>>> store(otherObject). because we had integrity violations.
>>>
>>> jakob
>>>
>>> Armin Waibel wrote:
>>>
>>>> Hi Jakob,
>>>>
>>>> Jakob Braeuchi wrote:
>>>>
>>>>> hi all, armin
>>>>>
>>>>> there are two new testcases failing in class MtoNMapping 
>>>>> testInsertWithIndirectionTable and testInsertWithIndirectionTable_2.
>>>>> imo these cases fail because we do not have persons in the project !
>>>>> and thus the m:n implementors for the project are deleted.
>>>>>
>>>> hmm, but in class-descriptor for Person a collection-descriptor with 
>>>> auto-update true for Project classes is set. OK I don't have persons 
>>>> in the project object, but why should this prevent creation of 
>>>> Roles. One Role(entry in indirection table) was created, the second 
>>>> not?
>>>>
>>>> This test creates (store two new Person objects with same new 
>>>> Project object) --->
>>>> one new Project (in PERSON table) OK
>>>> two new Persons (in PROJECT table) OK
>>>> one new Role (in PERSON_PROJECT table) ??
>>>>
>>>> I checked in this test case because I assume it is a bug. Either I 
>>>> get two Role entries or I get none entry. Why does OJB create one Role?
>>>>
>>>> regards,
>>>> Armin
>>>>
>>>>> jakob
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>>>>> For additional commands, e-mail: ojb-dev-help@db.apache.org
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>>>> For additional commands, e-mail: ojb-dev-help@db.apache.org
>>>>
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-dev-help@db.apache.org
>>>
>>>
>>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-dev-help@db.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message