You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by jg...@renr.es on 2003/08/16 22:46:10 UTC
Problem with 1:m relation (ODMG, DList)
Hi,
I´ve must be really stupid but, after read tutorials, eMails, source code...
I´ve not be able to run my 1:m code.
Two classes A and B, with A <--- B relation (1:m)
public class A
{
private int id;
private DList listB;
private String name;
public void A()
{
listB = new DListImpl() <---- is this correct or must be use
OJB.getInstance().newDList()???
}
}
public class B
{
private int id;
private int idA;
private A a;
}
In repository.xml must I put a reference-descriptor in class-descriptor for
class B?
<reference-descriptor name="a" classref="es.jgm.docmanager.db.empresa.A">
<foreignkey field-ref="idA"/>
</reference-descriptor>
In collection-descriptor for class A I´ve put
org.apache.ojb.odmg.collections.DListImpl
1) I create a new A object and store in DB using ODMG api.
2) I create a DList using odmg.newDList();
3) Retrieve all B objcets from DB
4) Iterate from all B objects and put the A id in B idA
5) Set list.add( b ) for each iteration
6) Add list in A using setListB( list )
7) Store A
Nothing happends.
I´ve tried without 4) point´, I´ve tried to put B.setA( a ) in point 4),
I´ve tried both ( setIdA() and setA() ) in point 4)
I´ve tried to clean the cache before, during, after to obtain de objects (A
and B-collection) from database.
Nothing happends.
I´ve using ojb rc4, jdk 1.4.1_01, MySql.
Any idea?
Greetings
Jose Galiana
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Problem with 1:m relation (ODMG, DList)
Posted by Christian Pesch <ch...@coremedia.com>.
jgaliana@renr.es wrote:
>Ok, I´ve just to rewrite all code with PB api, using Vector and
>RemovalAwareCollection and it works!!!!
>
Try to use the ODMG instead of the PB API now.
That worked for me, too. But I had problems
using HashSet for collections (see previous
mail "Collection problem" from 07.08.2003).
--
Christian
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Problem with 1:m relation (ODMG, DList)
Posted by jg...@renr.es.
Ok, I´ve just to rewrite all code with PB api, using Vector and
RemovalAwareCollection and it works!!!!
But, why do not DList and ODMW work? I´ve seen DListImplementatio source
code and I don´t recongnize any piece of code to call ODMG (PB) api..
jose Galiana
> jgaliana@renr.es wrote:
>
>>Hi,
>>
>>I´ve must be really stupid but, after read tutorials, eMails, source
>>code... I´ve not be able to run my 1:m code.
>>
>>Two classes A and B, with A <--- B relation (1:m)
>>
>>public class A
>>{
>> private int id;
>> private DList listB;
>> private String name;
>>
>> public void A()
>> {
>> listB = new DListImpl() <---- is this correct or must be use
>>OJB.getInstance().newDList()???
>> }
>>}
>>
>>
>
> Do you rely on using DList? Or what about
>
> /**
> * @ojb.collection element-class-ref="B"
> * foreignkey="idA"
> * orderby="id"
> */
> private List listB = new Vector();
>
> --
> Christian
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Problem with 1:m relation (ODMG, DList)
Posted by Christian Pesch <ch...@coremedia.com>.
jgaliana@renr.es wrote:
>Hi,
>
>I´ve must be really stupid but, after read tutorials, eMails, source code...
>I´ve not be able to run my 1:m code.
>
>Two classes A and B, with A <--- B relation (1:m)
>
>public class A
>{
> private int id;
> private DList listB;
> private String name;
>
> public void A()
> {
> listB = new DListImpl() <---- is this correct or must be use
>OJB.getInstance().newDList()???
> }
>}
>
>
Do you rely on using DList? Or what about
/**
* @ojb.collection element-class-ref="B"
* foreignkey="idA"
* orderby="id"
*/
private List listB = new Vector();
--
Christian
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org