我使用Spring+Hibernate+MySQL for web应用程序进行开发。但是在过去的一周里,我总是在尝试运行orgdao.findAll()获取所有组织时遇到“nested exception is org.springframework.dao.invalidDataAccessResourceUsageException:”异常。即使我评论所有的关系属性,但仍然没有幸运。以下是代码:
@Entity
@Table(name = "tb_org")
public class OrgEntity extends CommonEntity {
private static final long serialVersionUID = 1L;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name="parent_id")
private OrgEntity parent;
@Length(min=1, max=255)
private String parentIds;
/*
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name="area_id")
private Area area;
*/
@Length(min=0, max=100)
private String code;
@Length(min=1, max=100)
private String name;
private Integer type;
private Integer grade;
@Length(min=0, max=255)
private String address;
@Length(min=0, max=100)
private String zipCode;
@Length(min=0, max=100)
private String master;
@Length(min=0, max=200)
private String phone;
@Length(min=0, max=200)
private String fax;
@Length(min=0, max=200)
private String email;
/*
@OneToMany(mappedBy = "orgEntity", fetch=FetchType.LAZY)
@JsonIgnore
private List<UserEntity> userList = Lists.newArrayList();
*/
@OneToMany(mappedBy = "parent", fetch=FetchType.LAZY)
@JsonIgnore
private List<OrgEntity> childList = Lists.newArrayList();
public OrgEntity getParent() {
return parent;
}
public void setParent(OrgEntity parent) {
this.parent = parent;
}
public String getParentIds() {
return parentIds;
}
public void setParentIds(String parentIds) {
this.parentIds = parentIds;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Integer getGrade() {
return grade;
}
public void setGrade(Integer grade) {
this.grade = grade;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getZipCode() {
return zipCode;
}
public void setZipCode(String zipCode) {
this.zipCode = zipCode;
}
public String getMaster() {
return master;
}
public void setMaster(String master) {
this.master = master;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getFax() {
return fax;
}
public void setFax(String fax) {
this.fax = fax;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
/*
public List<UserEntity> getUserList() {
return userList;
}
public void setUserList(List<UserEntity> userList) {
this.userList = userList;
}
*/
public List<OrgEntity> getChildList() {
return childList;
}
public void setChildList(List<OrgEntity> childList) {
this.childList = childList;
}
public static long getSerialversionuid() {
return serialVersionUID;
}
}
@MappedSuperclass
public class CommonEntity extends GenericEntity {
private static final long serialVersionUID = 1L;
/**
* the createUser
*/
/*
@ManyToOne(cascade={CascadeType.REFRESH}, fetch=FetchType.LAZY)
@JoinColumn(name="createUserId")
@JsonIgnoreProperties( value={"hibernateLazyInitializer","handler"})
private UserEntity createUser;
*/
/**
* The createDate.
*/
@Column(name="createDate")
@CreatedDate
private Date createDate;
/**
* The lastModifyUser.
*/
/*
@ManyToOne(cascade={CascadeType.REFRESH},fetch=FetchType.LAZY)
@JoinColumn(name="lastModifyUser_id")
@JsonIgnoreProperties( value={"hibernateLazyInitializer","handler"})
private UserEntity lastModifyUser;
*/
/**
* The lastModifyDate.
*/
@Column(name="lastModifyDate")
@LastModifiedDate
private Date lastModifyDate;
/*
@PrePersist
public void preSave() {
if((this.getId() == null) && (this.createUser == null)) {
this.createDate = new Date();
this.lastModifyDate = new Date();
//this.createUser = UserUtil.getCurrentUser();
//this.lastModifyUser = UserUtil.getCurrentUser();
} else {
this.lastModifyDate = new Date();
//this.lastModifyUser = UserUtil.getCurrentUser();
}
}
public UserEntity getCreateUser() {
return createUser;
}
public void setCreateUser(UserEntity createUser) {
this.createUser = createUser;
}
*/
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
/*
public UserEntity getLastModifyUser() {
return lastModifyUser;
}
public void setLastModifyUser(UserEntity lastModifyUser) {
this.lastModifyUser = lastModifyUser;
}
*/
public Date getLastModifyDate() {
return lastModifyDate;
}
public void setLastModifyDate(Date lastModifyDate) {
this.lastModifyDate = lastModifyDate;
}
public static long getSerialversionuid() {
return serialVersionUID;
}
}
请帮忙弄清楚。欢迎任何建议。提前道谢。
您对资源的访问权限无效,请读取类InvalidDataAccessResourceUsageException:
错误使用数据访问资源时引发的异常。例如,在使用RDBMS时指定错误的SQL时引发。特定于资源的子类由具体的数据访问包提供。
如能提供任何帮助,我将不胜感激。 谢谢!
我在Spring中使用javax-validation和hibaernate-validator进行表单验证。而不是Spring所必需的基本JAR文件。 我在某处读到spl4j版本也受到关注,所以我也告诉大家: 错误的原因会不会是由于slf4j和log4j的兼容性? 我使用基于注释的验证。
我正在获取dynamo db中的所有记录,对于每条记录,我都要对一个外部服务进行多线程调用。 但是我得到了这个错误: 嵌套异常是java.util.concurrent.executionException:org.springframework.web.client.HttpServererRoreXception:500 null] 编辑: 错误的完整堆栈跟踪: org.springframe
我在我的项目中使用Spring引导和Spring数据,我有两个类: 第二类是: 添加任务的方法: 当我试图添加一个新的任务,它给出了这个错误: “找不到id为2的com.carpooling.entity.Station;嵌套异常为javax.persistence.EntityNotFoundException:找不到id为2的com.carpooling.entity.Station” 下面是
异常: 嵌套任务透传 重新处理生成器嵌套,需要将子生成器异常抛向父生成器。 当生成器迭代过程发生未捕获异常,生成器将会被关闭,Generator::valid返回false,未捕获异常会从生成器内部被抛向父作用域,嵌套子生成器内部的未捕获异常必须最终被抛向根生成器的calling frame,PHP7中yield-from对嵌套子生成器resume时产生的异常,采取goto try_again传递
当我尝试连接到Oracle数据库时,出现了以下问题。 有例外 此reportMapper.xml