Hi,
I'm using hibernate-core 3.3.2.GA, hibernate-annotations 3.4.0.GA, hibernate-entitymanager 3.4.0.GA with javax.persistence persistence-api 1.0.
Occasionally, I get the following the stack-trace when I'm running many loads one after the other:
Code:
Caused by: java.lang.NullPointerException
at org.hibernate.event.def.AbstractLockUpgradeEventListener.upgradeLock(
AbstractLockUpgradeEventListener.java:60)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromSessionCache
(DefaultLoadEventListener.java:488)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEv
entListener.java:378)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEven
tListener.java:165)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultL
oadEventListener.java:223)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEv
entListener.java:126)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:906)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:874)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:590)
at org.hibernate.type.EntityType.resolve(EntityType.java:412)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:
139)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.j
ava:877)
at org.hibernate.loader.Loader.doQuery(Loader.java:752)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Lo
ader.java:259)
at org.hibernate.loader.Loader.loadCollection(Loader.java:2019)
at org.hibernate.loader.collection.CollectionLoader.initialize(Collectio
nLoader.java:59)
at org.hibernate.persister.collection.AbstractCollectionPersister.initia
lize(AbstractCollectionPersister.java:587)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onIn
itializeCollection(DefaultInitializeCollectionEventListener.java:83)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:
1744)
at org.hibernate.collection.AbstractPersistentCollection.initialize(Abst
ractPersistentCollection.java:366)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPe
rsistentCollection.java:108)
at org.hibernate.collection.AbstractPersistentCollection.readElementExis
tence(AbstractPersistentCollection.java:164)
at org.hibernate.collection.PersistentBag.contains(PersistentBag.java:26
2)
at java.util.Collections$UnmodifiableCollection.contains(Collections.jav
a:1000)
at
my code here
Afterwards, when I run the failed load again it works. Thus, I can't get a reproducible error unfortunately. Looking at the hibernate code where it fails:
Code:
public class AbstractLockUpgradeEventListener extends AbstractReassociateEventListener {
private static final Logger log = LoggerFactory.getLogger(AbstractLockUpgradeEventListener.class);
/**
* Performs a pessimistic lock upgrade on a given entity, if needed.
*
* @param object The entity for which to upgrade the lock.
* @param entry The entity's EntityEntry instance.
* @param requestedLockMode The lock mode being requested for locking.
* @param source The session which is the source of the event being processed.
*/
protected void upgradeLock(Object object, EntityEntry entry, LockMode requestedLockMode, SessionImplementor source) {
if ( requestedLockMode.greaterThan( entry.getLockMode() ) ) { // <------- NullPointerException here !!!
// The user requested a "greater" (i.e. more restrictive) form of
// pessimistic lock
I'm not using any explicit Locking...just a simple transaction which rollbacks or commits. Please could someone tell me why I sometimes get a NullPointerException at this hibernate code?
Thanks..