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]



Reply via email to