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 Shawn Vincent <sv...@northpacific.com> on 2003/04/11 19:24:00 UTC
JDO m:n relationships
I am trying to use a Collection in a PersistenceCapable class to create a
relationship. I have followed the examples in the OJB tutorials to set up
the repository to be aware of the relationship. I can see the query taking
place, but no objects are ever placed in the collection, even though they
exist in the database. I am using an association table to map the
relationship. I am wondering if I need an extension tag in the .jdo file
for OJB to be able to work correctly. If anyone has been successful at
this, your help would be greatly appreciated.
Thanks,
Shawn Vincent
Re: JDO m:n relationships
Posted by Susanne Sherba <Su...@Colorado.EDU>.
Hi Shawn,
I played around with the JDO API a bit. To get the m:n mappings to work,
I ended up having to call makePersistent on the object I wanted to store
in the collection before I added it to the collection.
For example trying to store "a" in collection _attributes:
tx = manager.currentTransaction();
tx.begin();
manager.makePersistent(a);
tx.commit();
tx = manager.currentTransaction();
tx.begin();
_attributes.add(a);
tx.commit();
I'd be curious to know if this works for you.
Susanne
On Fri, 11 Apr 2003, Shawn Vincent wrote:
> I am trying to use a Collection in a PersistenceCapable class to create a
> relationship. I have followed the examples in the OJB tutorials to set up
> the repository to be aware of the relationship. I can see the query taking
> place, but no objects are ever placed in the collection, even though they
> exist in the database. I am using an association table to map the
> relationship. I am wondering if I need an extension tag in the .jdo file
> for OJB to be able to work correctly. If anyone has been successful at
> this, your help would be greatly appreciated.
>
> Thanks,
> Shawn Vincent
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>