Hi,
I'm trying to use long transactions to update persistent objects loaded
in previous transactions. I'm also using oracle sequences to generate
primary keys.
When trying to commit the "UPDATED" changes, the sequence gets somehow
involved and I don't understand why...
i'm getting the following exception:
org.exolab.castor.jdo.PersistenceException: The identity of a data
object of type com.perfuse.domain.Company, has been changed from 109,373
to 109,376 since it is loaded/create/update.
at org.exolab.castor.persist.ClassMolder.preStore(ClassMolder.java:1126)
at org.exolab.castor.persist.LockEngine.preStore(LockEngine.java:723)
at
org.exolab.castor.persist.TransactionContext.prepare(TransactionContext.java:1379)
at
org.exolab.castor.jdo.engine.DatabaseImpl.commit(DatabaseImpl.java:499)
at Runner.main(Runner.java:89)
Is this a bug or i'm doing something wrong....Here's the code and the mapping:
db.begin();
CompanyPeer cp = new CompanyPeer();
company = cp.findBySymbol("ZZZZZ");
company.setName("Updated Name");
db.update(company);
db.commit();
<class name="com.perfuse.domain.Company" identity="id"
key-generator="COMPANY_SEQ">
<map-to table="company" xml="company" />
<field name="id" type="long">
<sql name="id" type="numeric" />
<bind-xml node="attribute"/>
</field>
<field name="symbol" type="string">
<sql name="symbol" type="varchar" />
<bind-xml node="text" />
</field>
<field name="name" type="string">
<sql name="name" type="varchar" />
<bind-xml node="text" />
</field>
</class>
<key-generator name="SEQUENCE" alias="COMPANY_SEQ">
<param name="sequence" value="COMPANY_SQ"/>
</
key-generator>