Alessandro Vincelli wrote:
Ok,  I'am trying in other ways,
but I have other problems.
Can you hel me in a correct
...
Identity oid = new Identity(e, broker);
...
b = (Utenti) persistenceManager.getObjectById(oid, false);
...
thanks in advance


To create Identity objects you should use Identity oid = broker.serviceIdentity().buildIdentity(...) this method allows to build Identity objects based on a object itself or on the used PK.

If you want to use JDO-api in production environment I recommend to use
JPOX, because OJB-JDO is only a prototype based on jdori (JDO2.0 will be
supported in OJB2.0).

regards,
Armin



Armin Waibel ha scritto:

Hi Alessandro,

Alessandro Vincelli wrote:


I use this simple code to retrieve row,
but after this code the db sequence of Utenti table is autoincrement.
Why?
Thanks,Ale


//1. Get the PersistenceManager PersistenceManager persistenceManager = jdo.getPersistenceManager(); Utenti e = new Utenti(); e.setId_utente(bean.getId_utente()); PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker(); Identity oid = new Identity(e, broker);


When you create an Identity object for a new (not persisted) object, OJB
try to lookup/set a valid PK for the object, thus the sequence will be
incremented (because the PK is null and OJB lookup a valid sequence for
the new object).

regards,
Armin



       Utenti b = new Utenti();
       //    2. start transaction
       persistenceManager.currentTransaction().begin();
       // 3. Get the Object based on the primary key
       b = (Utenti) persistenceManager.getObjectById(oid, false);
       // 4. Copy data to bean
       copyData(b, bean);
       // 5. End transaction
       persistenceManager.currentTransaction().commit();

---------------------------------------------------------------------
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]







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



Reply via email to