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 Luis Cruz <le...@netcabo.pt> on 2003/09/03 20:30:35 UTC

Unable to update collections

Hello,

We're experiencing a strange problem updating collections and we hope
that someone of you OJB Gurus can shed some light on this for us.

The situation is:

	1. An object "a1" of type A is created and inserted into the database.

	2. An object "b1" of type B is created and added to object "a1"'s list
of B's

The relevant snip of code used to update class A follows:

  beginTransaction();
  IA a = readAFromDB(someInfoAboutTheAWeWantToRead);
  IB b = new B();
  lockWrite(b);
  lockWrite(a);
  a.getListOfBs().add(b);
  confirmTransaction();

The problem:

Object "b1" is not written to the database! However this is only
verified when our server is under significant load. When the load is
reduced everything works fine and object "b1" shows up in the database.

What we are using (I hope this is sufficient to understand the cause):
  - OJB version 1.0rc3
  - Cache implementation:
	org.apache.ojb.broker.cache.ObjectCacheDefaultImpl
  - Isolation level: "read-committed".

The relevant snip of the Class/Table mapping follows:

   <class-descriptor
          class="A"
          table="A"
   >
      <field-descriptor id="1"
         name="id"
         column="ID"
         jdbc-type="INTEGER"
         primarykey="true"
         autoincrement="true"
      />
     <collection-descriptor
                name="listOfBs"
		collection-class="org.apache.ojb.broker.util.collections.ManageableVector"
                element-class-ref="B"
                indirection-table="A_B"
                proxy="true"
                auto-retrieve="true"
                refresh="true">
        <fk-pointing-to-this-class column="KEY_A"/>
        <fk-pointing-to-element-class column="KEY_B"/>
     </collection-descriptor>
   </class-descriptor>

   <class-descriptor
          class="B"
          table="B"
   >
      <field-descriptor id="1"
         name="id"
         column="ID"
         jdbc-type="INTEGER"
         primarykey="true"
         autoincrement="true"
      />
   </class-descriptor>


Any help on this matter is GREATLY appreciated.

Thanks in advance,
Luis (M)



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


Re: Unable to update collections

Posted by ro...@bowtech.com.
You seem to be missing an auto-update="true" although this would not make
sense of the working when not under load.

This is all new to me though so i could be wrong.

Regards

Ross Rotherham
----- Original Message ----- 
From: "Luis Cruz" <le...@netcabo.pt>
To: "OJB Users List" <oj...@db.apache.org>
Sent: Wednesday, September 03, 2003 2:30 PM
Subject: Unable to update collections


>
> Hello,
>
> We're experiencing a strange problem updating collections and we hope
> that someone of you OJB Gurus can shed some light on this for us.
>
> The situation is:
>
> 1. An object "a1" of type A is created and inserted into the database.
>
> 2. An object "b1" of type B is created and added to object "a1"'s list
> of B's
>
> The relevant snip of code used to update class A follows:
>
>   beginTransaction();
>   IA a = readAFromDB(someInfoAboutTheAWeWantToRead);
>   IB b = new B();
>   lockWrite(b);
>   lockWrite(a);
>   a.getListOfBs().add(b);
>   confirmTransaction();
>
> The problem:
>
> Object "b1" is not written to the database! However this is only
> verified when our server is under significant load. When the load is
> reduced everything works fine and object "b1" shows up in the database.
>
> What we are using (I hope this is sufficient to understand the cause):
>   - OJB version 1.0rc3
>   - Cache implementation:
> org.apache.ojb.broker.cache.ObjectCacheDefaultImpl
>   - Isolation level: "read-committed".
>
> The relevant snip of the Class/Table mapping follows:
>
>    <class-descriptor
>           class="A"
>           table="A"
>    >
>       <field-descriptor id="1"
>          name="id"
>          column="ID"
>          jdbc-type="INTEGER"
>          primarykey="true"
>          autoincrement="true"
>       />
>      <collection-descriptor
>                 name="listOfBs"
> collection-class="org.apache.ojb.broker.util.collections.ManageableVector"
>                 element-class-ref="B"
>                 indirection-table="A_B"
>                 proxy="true"
>                 auto-retrieve="true"
>                 refresh="true">
>         <fk-pointing-to-this-class column="KEY_A"/>
>         <fk-pointing-to-element-class column="KEY_B"/>
>      </collection-descriptor>
>    </class-descriptor>
>
>    <class-descriptor
>           class="B"
>           table="B"
>    >
>       <field-descriptor id="1"
>          name="id"
>          column="ID"
>          jdbc-type="INTEGER"
>          primarykey="true"
>          autoincrement="true"
>       />
>    </class-descriptor>
>
>
> Any help on this matter is GREATLY appreciated.
>
> Thanks in advance,
> Luis (M)
>
>
>
> ---------------------------------------------------------------------
> 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