-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: NPE, caching & PersistentSet.initializeFromCache
PostPosted: Fri Oct 31, 2014 10:18 am 
Newbie

Joined: Fri Oct 31, 2014 9:58 am
Posts: 1
I'm getting a NPE on a Model called IssueStepFieldTypeModel at

Code:
@Override
public int hashCode() {
    final int hash = 5;
    return 53 * hash + getCode().hashCode();
}

getCode() is null even though code is annotated @NotNull and the instance is indeed in the database with all its data.
further, the code field at point of creation of the model, and before the call to persist, is guaranteed not null and unique.

the error is being thrown in the call to getIssueStepFieldTypeById. in the web app the user is requesting to display the model so the query really can't fail.

this error occured after adding the following line to hibernate.cfg.xml

Code:
< class-cache class="hae.op.issu.server.model.IssueStepFieldTypeModel" include="all" usage="read-write" />

remove the line and all is well. the error is happening in both my local instance of tomcat (which is single user) and on the development server with a load balancer

FieldType has a reference to its 'owner' StepType
Code:
@ManyToOne(fetch = FetchType.EAGER, optional = false)
@JoinColumn(name = "ISSUETYPE_STEP_TYPE_ID", referencedColumnName = "ID")
@NotNull
private IssueStepTypeModel issueStepType;


StepType has a Set of the FieldTypes it 'owns'
Code:
@OneToMany(fetch = FetchType.EAGER, mappedBy = "issueStepType")
private Set<IssueStepFieldTypeModel> issueStepFieldTypes;


abreviated stack trace follows

any assistance would be greatly appreciated

thank you

Code:
java.lang.NullPointerException
at hae.op.issu.server.model.IssueStepFieldTypeModel.hashCode(IssueStepFieldTypeModel.java:128)
at java.util.HashMap.hash(HashMap.java:362)
at java.util.HashMap.put(HashMap.java:492)
at java.util.HashSet.add(HashSet.java:217)
at org.hibernate.collection.PersistentSet.initializeFromCache(PersistentSet.java:149)
at org.hibernate.cache.entry.CollectionCacheEntry.assemble(CollectionCacheEntry.java:58)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.initializeCollectionFromCache(DefaultInitializeCollectionEventListener.java:159)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:71)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1853)
at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:479)
at org.hibernate.engine.StatefulPersistenceContext.initializeNonLazyCollections(StatefulPersistenceContext.java:899)
at org.hibernate.event.def.DefaultLoadEventListener.assembleCacheEntry(DefaultLoadEventListener.java:689)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromSecondLevelCache(DefaultLoadEventListener.java:604)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:459)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:227)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:285)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152)
.....................................
at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240)
at com.sun.proxy.$Proxy746.find(Unknown Source)
at hae.cf.srv.jpa.AbstractDao.findById(AbstractDao.java:56)
at hae.op.issu.server.dao.IssueStepFieldTypeDaoJpa.findById(IssueStepFieldTypeDaoJpa.java:12)

...................

at com.sun.proxy.$Proxy760.findById(Unknown Source)
at hae.op.issu.server.service.IssueStepFieldTypeServiceImpl.getIssueStepFieldTypeById(IssueStepFieldTypeServiceImpl.java:47)
.................................


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.