我在名为IssueStepFieldTypeModel的模型上获得了NPE 在
@Override
public int hashCode() {
final int hash = 5;
return 53 * hash + getCode().hashCode();
}
即使代码注释为@NotNull,getCode()也为null 并且实例确实在数据库中包含其所有数据。
在调用getIssueStepFieldTypeById时抛出错误。 在Web应用程序中,用户请求显示模型以进行查询 真的不会失败。
将以下行添加到hibernate.cfg.xml
后发生此错误 < class-cache class="hae.op.issu.server.model.IssueStepFieldTypeModel" include="all" usage="read-write" />
删除该行,一切顺利。 错误发生在我的本地tomcat实例上 (这是单个用户) 并在具有负载均衡器的开发服务器上
FieldType引用了其所有者&#39;步骤类型
@ManyToOne(fetch = FetchType.EAGER, optional = false)
@JoinColumn(name = "ISSUETYPE_STEP_TYPE_ID", referencedColumnName = "ID")
@NotNull
private IssueStepTypeModel issueStepType;
StepType有一组它拥有的FieldTypes&#39;
@OneToMany(fetch = FetchType.EAGER, mappedBy = "issueStepType")
private Set<IssueStepFieldTypeModel> issueStepFieldTypes;
跟随堆栈跟踪
非常感谢任何协助
谢谢
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)
.................................