org.hibernate.AssertionFailure在criteria.uniqueResult期间发生

huangapple go评论82阅读模式
英文:

org.hibernate.AssertionFailure during criteria.uniqueResult

问题

我正在从一个名为pHistory的表中选择数据,该表与CenterLog实体没有任何关联,然而,我仍然收到Hibernate错误投诉CenterLog实体中的空id。

日志内容如下:

org.hibernate.AssertionFailure: 在com.audit.entity.CenterLog条目中存在空id(在异常发生后不要刷新Session)
at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:78) ~[hibernate-core-3.3.1.GA.jar:3.3.1.GA]
at org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:187) ~[hibernate-core-3.3.1.GA.jar:3.3.1.GA]
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:143) ~[hibernate-core-3.3.1.GA.jar:3.3.1.GA]
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:219) ~[hibernate-core-3.3.1.GA.jar:3.3.1.GA]
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99) ~[hibernate-core-3.3.1.GA.jar:3.3.1.GA]
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:58) ~[hibernate-core-3.3.1.GA.jar:3.3.1.GA]
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:996) ~[hibernate-core-3.3.1.GA.jar:3.3.1.GA]
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1589) ~[hibernate-core-3.3.1.GA.jar:3.3.1.GA]
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306) ~[hibernate-core-3.3.1.GA.jar:3.3.1.GA]
at org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:328) ~[hibernate-core-3.3.1.GA.jar:3.3.1.GA]

据我理解,uniqueResult并不执行任何保存操作,但不确定为什么我仍然会遇到这个问题。

英文:

I am selecting data from a table which is call pHistory, this table does not have any relationShip with CenterLog entity, however, I am still getting hibernate error complain that null id in CenterLog entity.

The log is as follow:

org.hibernate.AssertionFailure: null id in com.audit.entity.CenterLog entry (don't flush the Session after an exception occurs)
	at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:78) ~[hibernate-core-3.3.1.GA.jar:3.3.1.GA]
	at org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:187) ~[hibernate-core-3.3.1.GA.jar:3.3.1.GA]
	at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:143) ~[hibernate-core-3.3.1.GA.jar:3.3.1.GA]
	at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:219) ~[hibernate-core-3.3.1.GA.jar:3.3.1.GA]
	at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99) ~[hibernate-core-3.3.1.GA.jar:3.3.1.GA]
	at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:58) ~[hibernate-core-3.3.1.GA.jar:3.3.1.GA]
	at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:996) ~[hibernate-core-3.3.1.GA.jar:3.3.1.GA]
	at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1589) ~[hibernate-core-3.3.1.GA.jar:3.3.1.GA]
	at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:306) ~[hibernate-core-3.3.1.GA.jar:3.3.1.GA]
	at org.hibernate.impl.CriteriaImpl.uniqueResult(CriteriaImpl.java:328) ~[hibernate-core-3.3.1.GA.jar:3.3.1.GA]

As my understanding, uniqueResult is not doing any save event, but not sure I am still hitting this.

答案1

得分: 1

错误信息说:(在异常发生后不要刷新Session): 之前发生了另一个异常,它是问题的原因。

你需要找到那个其他的异常并修复它。

英文:

The error message says (don't flush the Session after an exception occurs): there was another exception earlier and it the cause of the problem.

You need to find that other exception and fix it.

huangapple
  • 本文由 发表于 2020年10月9日 15:46:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/64275962.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定