Hi,

----- Original Message -----
From: "Ajitesh Das" <[EMAIL PROTECTED]>
To: "OJB Users List" <[EMAIL PROTECTED]>; "Armin Waibel"
<[EMAIL PROTECTED]>
Sent: Sunday, July 06, 2003 12:25 AM
Subject: RE: inserting "reused" objects in a loop


> Hi:
>
> >>   (ii) set the DB Id to zero.
> >> broker.beginTransaction();
> >>         Person p = new Person();
> >>         p.setFirstname("no_1_"+timestamp);
> >>         p.setLastname("no_1_"+timestamp);
> >>         broker.store(p);
> >>         p.setId(0);  <<<<========set the db id to 0
> >does PK field-descriptor in Person support autoincrement?
> >if not, you have to set id by your own.
> yes! My PK field descriptor does support auto increment.
> I think, PB is listening/expecting the property change message for ID
> property when
> it is recording the property values to record in database.
>
> One more question, I have extended your code to run query the table
and
> update them:
> here is the extension [ Test object is actually your Person object ]
>     broker = PersistenceBrokerFactory.defaultPersistenceBroker();
>     broker.beginTransaction();
>           Iterator it = broker.getIteratorByQuery(new
> QueryByCriteria(zs.getClass(),new Criteria()));
>     Test tq = null;
>     int i = 1;
>     while ( it.hasNext() ) {
> tq = (Test)it.next();
> System.out.println((new Integer(i++)).toString()+":Query ZonaModeler
> object of Test");
> System.out.println("Query posx:" + Integer.toString(tq.getPosX()));
> System.out.println("Query posy:" + Integer.toString(tq.getPosY()));
> System.out.println("<<<<<<<2>>>>>>>Updatinging attributes of Test");
> tq.setPosX(10000+tq.getPosX());
> tq.setPosY(10000+tq.getPosY());
> System.out.println("Getting posx:" + Integer.toString(tq.getPosX()));
> System.out.println("Getting posy:" + Integer.toString(tq.getPosY()));

hmm, seems they same problem as before.
Try to do broker.removeFromCache(tq) before store.
By the way, this test works with latest version too.

regards,
Armin

> broker.store(tq); <<============Does not work properly
>     }
>     broker.commitTransaction();
> All the system.out statements are showing the right results, but the
last
> broker.store() is not working,
> i.e data is not getting stored.
>
> Thanks a lot in advance for your help.
>
> ~ajitesh
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>



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

Reply via email to