HIbernate异常错误,No row with the given identifier exists

J2EE 码拜 8年前 (2016-05-28) 2266次浏览
org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException : No row with the given identifier exists: [com.sunking.em.solution.domain.DispositionSolution#402880ff552a0c1f01552a27dc500002]; nested exception is org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.sunking.em.solution.domain.DispositionSolution#402880ff552a0c1f01552a27dc500002]
DispositionSolution表用的是hibernate注解形式,


package com.sunking.framework.main.domain;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
/**
* <p>字典内容记录字典项信息,于字典是多对一关系。</p>
*    字典有单级字典,也有多级字典。多级字典的关系使用字典内容表中的parentId来维系。
*    判断字典的级数,采用目前的方式有些困难,在使用过程中,使用CascadeCombox组件,假如存在下一级,则生成combox,否则不显示
* <p>@(#) CommonServiceImpl.java 创建日期 六  6月 05 09:46:12 +0800 2010</p>
* <p>@version 0.1 </p>
*/
@NamedQueries({
@NamedQuery(name=”listDictContent”,query=”select t from DictContent t where t.dict.code=? and t.valided=true order by t.code  asc”),
@NamedQuery(name=”listAllDictContent”,query=”select t from DictContent t where t.dict.code=?”),
@NamedQuery(name=”getDictContentByCodeOrName”,query=”select t from DictContent t where t.dict.dictId=? and (t.code=? or t.name=?)”),
@NamedQuery(name=”codeParseChinese”,query=”select t from DictContent t where t.dict.code=? and t.code=?”),
@NamedQuery(name=”listCommonDictContent”,query=”select d from DictContent d where d.dict.code=? and d.common=true and d.valided=true”),
@NamedQuery(name=”getDictContentByCode” ,query=”select t from DictContent t where t.code=? and t.dict.code=?”)
})
@Entity
@Table(name=”DictContent”)
public class DictContent  implements Serializable{
private String dictContentId;
private Dict dict;
private String code;
private String name;
private Date sysTime;
private DictContent parent;
private Boolean common;//能否是常用
private Boolean valided;//能否有效
@Basic
public Boolean getValided(){
return this.valided;
}
public void setValided(Boolean valided) {
this.valided=valided;
}
@Basic
public Boolean getCommon(){
return this.common;
}
public void setCommon(Boolean common) {
this.common=common;
}
@ManyToOne(targetEntity=DictContent.class,fetch=FetchType.EAGER)
@JoinColumn(name=”parentid”)
@NotFound(action=NotFoundAction.IGNORE)
public DictContent getParent(){
return this.parent;
}
public void setParent(DictContent parent) {
this.parent=parent;
}
@Id
@GeneratedValue(generator=”system-uuid”)
@GenericGenerator(name=”system-uuid”,strategy=”uuid”)
public String getDictContentId() {
return dictContentId;
}
public void setDictContentId(String dictContentId) {
this.dictContentId = dictContentId;
}
@ManyToOne(targetEntity=Dict.class,fetch=FetchType.EAGER)
@JoinColumn(name=”dictId”)
public Dict getDict() {
return dict;
}
public void setDict(Dict dict) {
this.dict = dict;
}
@Basic
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
@Basic
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Basic
public Date getSysTime() {
return sysTime;
}
public void setSysTime(Date sysTime) {
this.sysTime = sysTime;
}
}

解决方案

40

先去数据库里查一下,是不是有这条记录。
然后看看,写入数据库的时候,能否真的写入了。

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明HIbernate异常错误,No row with the given identifier exists
喜欢 (0)
[1034331897@qq.com]
分享 (0)