replicate() of non-versioned entiy can result in wrong value for version in entity cache

Description

if replication is called on a non-versioned entity and the entity already exists in the db it can result in the persister it self being stored as the version value for the entity (because AbstractEntityPersister.getCurrentVersion(..) returns any object if row exists and non-versioned).

This result in a NPE in Lock.isPuttable because version is suddenly not null and thus a comparison is done wrongly.

eg.
Caused by: java.lang.NullPointerException
at org.hibernate.cache.ReadWriteCache$Lock.isPuttable(ReadWriteCache.java:460)
at org.hibernate.cache.ReadWriteCache.put(ReadWriteCache.java:155)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:153)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
at org.hibernate.loader.Loader.doQuery(Loader.java:717)

Environment

None

Activity

Show:
Max Rydahl Andersen
January 24, 2007, 4:47 PM

fixed in trunk / 3.2.

replicate now explicilty null's out oldVersion in case of non-versioned persister/entity

Assignee

Max Rydahl Andersen

Reporter

Max Rydahl Andersen

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Priority

Major
Configure