Thank you, that makes sense as it works for collections.

Cheers
Neil

-----Original Message-----
From: Thomas Mahler [mailto:[EMAIL PROTECTED]]
Sent: 27 November 2002 19:35
To: OJB Users List
Subject: Re: should auto-delete be needed for ODMG


Hi Neil,

I fear the docs are a bit unprecise here.
For your scenario you must use auto-delete="true".
The doc is referring to DList collection mainly!

cheers,
Thomas

Neil Blue wrote:
> Hello,
> 
> I have set up a simple test with OJB 0.9.7.
> 
> I have two classes Simple and Simple2, where Simple contains a Simple2
> attribute. I then set up a repository for these classes:
> 
> <class-descriptor
>   class="com.novobase.jaxbjdo.Simple"
>   table="simple">
>         
> <field-descriptor id="1"
>    name="id"
>    column="ID"
>     jdbc-type="INTEGER"
>     primarykey="true"
>     autoincrement="true"/>
>                
>  <field-descriptor id="2"
>     name="idSimple2"
>     column="simpleid"
>     jdbc-type="INTEGER"/>
> 
>  <reference-descriptor
>  refresh="true"
>  auto-retrieve="true"         
> <!-- I need to add auto-delete="true" here for ODMG to auto delete, though
> the 
> documentation says you should not use this setting with ODMG -->
>  name="simple2"
>  class-ref="com.novobase.jaxbjdo.Simple2">
>       <foreignkey field-id-ref="2"/>
>  </reference-descriptor>
> 
> </class-descriptor>
>       
> <class-descriptor
>   class="com.novobase.jaxbjdo.Simple2"
>   table="simple2">
>         
>   <field-descriptor id="1"
>          name="id"
>          column="ID"
>          jdbc-type="INTEGER"
>          primarykey="true"
>          autoincrement="true"/>
> </class-descriptor>
> 
> for good measure here is my test code:
> 
> // open the database
> Implementation odmg = OJB.getInstance();
> Database db = odmg.newDatabase();
> db.open( "repository.xml", Database.OPEN_READ_WRITE );
> 
> // make simple
> Simple simple = new Simple();
> Simple2 simple2 = new Simple2();
> simple.setSimple2( simple2 );
> 
> // print the object
> System.err.println( simple );
> 
> // write the object
> Transaction tx = odmg.newTransaction();
> tx.begin();
> tx.lock( simple, Transaction.WRITE );
> tx.commit();
> 
> // query for the simple object
> tx.begin();
> OQLQuery query = odmg.newOQLQuery();
> query.create( "select * from com.novobase.jaxbjdo.Simple" );
> DList allObjects = ( DList ) query.execute();
> tx.commit();
> 
> // print the object
> System.err.println( allObjects );
> 
> // delete the object
> tx.begin();
> Iterator itor = allObjects.iterator();
> while ( itor.hasNext() )
> {
>       db.deletePersistent( itor.next() );
> }
> tx.commit();
> 
> // query for the simple2 object
> tx.begin();
> query = odmg.newOQLQuery();
> query.create( "select * from com.novobase.jaxbjdo.Simple2" );
> allObjects = ( DList ) query.execute();
> tx.commit();
> 
> // print the object
> System.err.println( allObjects );
> 
> Thanks
> Neil
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> 
> 
> 
> 




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to