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)
.................................