Hi,
You have to look at the state implementations in org.apache.ojb.odmg.states
to get an idea of the semantics of each of them.

StateOldClean.commit() is implemented as follows:
    /**
     * commit the associated transaction
     */
    public void commit(ObjectEnvelope mod, PersistenceBroker broker)
    {
    }

as you can see, there is no persistence operation, as an old clean object is
regarded as being in sync with the db. OJB won't perform an insert or update
here!

cheers,
Thomas

> -----Urspr�ngliche Nachricht-----
> Von: Jose Maria Lopez Lagunas [mailto:chema@;visual-limes.com]
> Gesendet: Mittwoch, 13. November 2002 10:26
> An: OJB Users List
> Betreff: ODMG States problem
> 
> 
> Hi.
> 
> I'm having a problem with the following code:
> ...
>     Transaction tx = null;
>     try {
>       tx = ojb.newTransaction();
>       tx.begin();
>       A a = getA(1); // Retrieves the object from the DB 
> using a OQL query
>       B b = new B();
>       b.setId(100);
>       db.makePersistent(b);
>       b.setName("PROBANDO");
>       b.setId_a(a.getId());
>       a.getLista().add(b);
>       db.deletePersistent(b);
>       a.getLista().remove(b);
>       tx.commit();
>     }
>     catch (Exception ex) {
>       tx.abort();
>     }
> ...
> 
> The mapping is:
> <class-descriptor class="prueba_ojb.A" table="A">
>   <field-descriptor id="1" name="id" column="ID" jdbc-type="INTEGER" 
> primarykey="true" />
>   <field-descriptor id="2" name="name" column="NAME" 
> jdbc-type="VARCHAR" />
>   <collection-descriptor name="lista" element-class-ref="prueba_ojb.B"
>     auto-retrieve="true" auto-update="false" 
> auto-delete="false" <!-- as 
> OJB advises to use with ODMG -->
>     orderby="id">
>     <inverse-foreignkey field-id-ref="3"/>
>   </collection-descriptor>
> </class-descriptor>
> 
> <class-descriptor class="prueba_ojb.B" table="B">
>   <field-descriptor id="1" name="id" column="ID" jdbc-type="INTEGER" 
> primarykey="true" />
>   <field-descriptor id="2" name="name" column="NAME" 
> jdbc-type="VARCHAR" />
>   <field-descriptor id="3" name="id_a" column="ID_A" 
> jdbc-type="INTEGER" />
> </class-descriptor>
> 
> I suppose OJB should do nothing since I create a new object 
> (class B), 
> make persistent, modify it and finally delete it. But this 
> object makes 
> the following transitions in its state:
> StateNewDirty -> StateNewDelete -> StateNewDirty -> StateOldClean
> So the object is stored in the database.
> 
> I don't know if there is a bug or I don't understand the ODMG 
> part of OJB.
> 
> Thank you in advance.
> 
> 
> --
> To unsubscribe, e-mail:   
<mailto:ojb-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:ojb-user-help@;jakarta.apache.org>



--
To unsubscribe, e-mail:   <mailto:ojb-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:ojb-user-help@;jakarta.apache.org>

Reply via email to