I have a simple case in which the version field is not updated.
1. I Create the entity
2. I change a property of the entity
3. I perform a find for the entity
All three steps are done in three seperate transactions. The version
field is updated in step 1 (from 0 to 1), as I expected. However the
version field is not updated in step 2. When the entity is returned
from the find, the version field is updated.
Is this perhaps related to the message from open jpa (An error
occurred ...)? If so, why is the version field updated in step 1 but
not in step 2? Or is this behaviour normal and the version field
shouldnt be updated at all...
TIA,
KlaasJan
// code
MailingList ml = new MailingList();
ml.setAddress("[EMAIL PROTECTED]");
logger.debug("Create id/version " + ml.getId() + "/" + ml.getVersion());
mailingListManager.create(ml); // just does a persist in a trx
logger.debug("Create id/version " + ml.getId() + "/" + ml.getVersion());
ml.setAddress("Hallo");
logger.debug("before update " + ml.getId() + "/" + ml.getVersion());
mailingListManager.update(ml); // does a merge and a persist in a trx
// I expected a higher version number here ...
logger.debug("after update " + ml.getId() + "/" + ml.getVersion());
ml = mailingListManager.find(ml.getId()); // just does a find
logger.debug("after find " + ml.getId() + "/" + ml.getVersion());
Logging:
// startup:
[main] openjpa.Runtime - An error occurred while registering a
ClassTransformer with PersistenceUnitInfo: name 'mailingStore', root
URL [file:/C:/dvl/MailingListManager/modules/Manager/target/classes/].
The error has been consumed. To see it, set your openjpa.Runtime log
level to TRACE. Load-time class transformation will not be available.
// create
MailingListTransactionalTestCase - Create id/version null/0
openjpa.Runtime - Starting OpenJPA 1.0.0
openjpa.jdbc.JDBC - Using dictionary class
"org.apache.openjpa.jdbc.sql.HSQLDictionary".
AbstractJpaDao - Persisting entity
[EMAIL PROTECTED]<null>,version=0,[EMAIL PROTECTED]
MailingListTransactionalTestCase - Create id/version 11601/1
// update
MailingListTransactionalTestCase - before update 11601/1
AbstractJpaDao - Merging entity
[EMAIL PROTECTED],version=1,address=Hallo]
AbstractJpaDao - Persisting entity
[EMAIL PROTECTED],version=1,address=Hallo]
MailingListTransactionalTestCase - after update 11601/1
// find
AbstractJpaDao - find entity .mailinglist.model.MailingList with id 11601
MailingListTransactionalTestCase - after find 11601/2