Java ORA-00942:表或视图不存在org.springframework.dao.InvalidDataAccessResourceUsageException:无法提取结果集
不确定我遗漏了什么,但当我在orm中添加一个有2个@id列的表SEMPLOYEES时,我得到了这个错误。当我在ORM查询中使用SEMPLYEES表时,我得到了这个错误。在ORM查询中没有SEMPLOYEES,服务可以正常工作,但我必须从这个表中获取一些数据,所以我必须使用它。任何帮助都将不胜感激。谢谢 我的实体类Java ORA-00942:表或视图不存在org.springframework.dao.InvalidDataAccessResourceUsageException:无法提取结果集,java,spring,oracle,hibernate,Java,Spring,Oracle,Hibernate,不确定我遗漏了什么,但当我在orm中添加一个有2个@id列的表SEMPLOYEES时,我得到了这个错误。当我在ORM查询中使用SEMPLYEES表时,我得到了这个错误。在ORM查询中没有SEMPLOYEES,服务可以正常工作,但我必须从这个表中获取一些数据,所以我必须使用它。任何帮助都将不胜感激。谢谢 我的实体类 package com.paychex.hrs.riskassessment.entity; import javax.persistence.*; import com.paych
package com.paychex.hrs.riskassessment.entity;
import javax.persistence.*;
import com.paychex.hrs.riskassessment.entity.keys.SEmployeesPK;
@Entity
@Table(name = "SEMPLOYEES", schema = "HRIS")
@IdClass(SEmployeesPK.class)
public class SEmployees {
@Id
@Column(name = "SEE_CLT_ID")
private Long seeCltId;
@Id
@Column(name = "SEE_EMP_NBR")
private Integer seeEmpNbr;
@Column(name = "SEE_LAST_NAME")
private String seeLastName;
@Column(name = "SEE_FIRST_NAME")
private String seeFirstName;
public Long getSeeCltId() {
return seeCltId;
}
public void setSeeCltId(Long seeCltId) {
this.seeCltId = seeCltId;
}
public Integer getSeeEmpNbr() {
return seeEmpNbr;
}
public void setSeeEmpNbr(Integer seeEmpNbr) {
this.seeEmpNbr = seeEmpNbr;
}
public String getSeeLastName() {
return seeLastName;
}
public void setSeeLastName(String seeLastName) {
this.seeLastName = seeLastName;
}
public String getSeeFirstName() {
return seeFirstName;
}
public void setSeeFirstName(String seeFirstName) {
this.seeFirstName = seeFirstName;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((seeCltId == null) ? 0 : seeCltId.hashCode());
result = prime * result + ((seeEmpNbr == null) ? 0 : seeEmpNbr.hashCode());
result = prime * result + ((seeFirstName == null) ? 0 : seeFirstName.hashCode());
result = prime * result + ((seeLastName == null) ? 0 : seeLastName.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
SEmployees other = (SEmployees) obj;
if (seeCltId == null) {
if (other.seeCltId != null)
return false;
} else if (!seeCltId.equals(other.seeCltId))
return false;
if (seeEmpNbr == null) {
if (other.seeEmpNbr != null)
return false;
} else if (!seeEmpNbr.equals(other.seeEmpNbr))
return false;
if (seeFirstName == null) {
if (other.seeFirstName != null)
return false;
} else if (!seeFirstName.equals(other.seeFirstName))
return false;
if (seeLastName == null) {
if (other.seeLastName != null)
return false;
} else if (!seeLastName.equals(other.seeLastName))
return false;
return true;
}
@Override
public String toString() {
return "SEmployees [seeCltId=" + seeCltId + ", seeEmpNbr=" + seeEmpNbr + ", seeLastName=" + seeLastName
+ ", seeFirstName=" + seeFirstName + "]";
}
}
===========================================================================================================
package com.paychex.hrs.riskassessment.entity.keys;
import javax.persistence.Column;
import javax.persistence.Id;
import java.io.Serializable;
public class SEmployeesPK implements Serializable {
private static final long serialVersionUID = 42L;
@Id
@Column(name = "SEE_CLT_ID")
private Long seeCltId;
@Id
@Column(name = "SEE_EMP_NBR")
private Integer seeEmpNbr;
public SEmployeesPK() {
}
public SEmployeesPK(Long seeCltId, Integer seeEmpNbr) {
this.seeCltId = seeCltId;
this.seeEmpNbr = seeEmpNbr;
}
public Long getSeeCltId() {
return this.seeCltId;
}
public void setSeeCltId(Long seeCltId) {
this.seeCltId = seeCltId;
}
public Integer getSeeEmpNbr() {
return this.seeEmpNbr;
}
public void setSeeEmpNbr(Integer seeEmpNbr) {
this.seeEmpNbr = seeEmpNbr;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((seeCltId == null) ? 0 : seeCltId.hashCode());
result = prime * result + ((seeEmpNbr == null) ? 0 : seeEmpNbr.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
SEmployeesPK other = (SEmployeesPK) obj;
if (seeCltId == null) {
if (other.seeCltId != null)
return false;
} else if (!seeCltId.equals(other.seeCltId))
return false;
if (seeEmpNbr == null) {
if (other.seeEmpNbr != null)
return false;
} else if (!seeEmpNbr.equals(other.seeEmpNbr))
return false;
return true;
}
@Override
public String toString() {
return "SEmployeesPK [seeCltId=" + seeCltId + ", seeEmpNbr=" + seeEmpNbr + "]";
}
}
========================================================================
package com.paychex.hrs.riskassessment.entity.keys;
import javax.persistence.Column;
import javax.persistence.Id;
import java.io.Serializable;
public class SEmployeesPK implements Serializable {
private static final long serialVersionUID = 42L;
@Id
@Column(name = "SEE_CLT_ID")
private Long seeCltId;
@Id
@Column(name = "SEE_EMP_NBR")
private Integer seeEmpNbr;
public SEmployeesPK() {
}
public SEmployeesPK(Long seeCltId, Integer seeEmpNbr) {
this.seeCltId = seeCltId;
this.seeEmpNbr = seeEmpNbr;
}
public Long getSeeCltId() {
return this.seeCltId;
}
public void setSeeCltId(Long seeCltId) {
this.seeCltId = seeCltId;
}
public Integer getSeeEmpNbr() {
return this.seeEmpNbr;
}
public void setSeeEmpNbr(Integer seeEmpNbr) {
this.seeEmpNbr = seeEmpNbr;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((seeCltId == null) ? 0 : seeCltId.hashCode());
result = prime * result + ((seeEmpNbr == null) ? 0 : seeEmpNbr.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
SEmployeesPK other = (SEmployeesPK) obj;
if (seeCltId == null) {
if (other.seeCltId != null)
return false;
} else if (!seeCltId.equals(other.seeCltId))
return false;
if (seeEmpNbr == null) {
if (other.seeEmpNbr != null)
return false;
} else if (!seeEmpNbr.equals(other.seeEmpNbr))
return false;
return true;
}
@Override
public String toString() {
return "SEmployeesPK [seeCltId=" + seeCltId + ", seeEmpNbr=" + seeEmpNbr + "]";
}
}
ORM
<named-native-query name="DistributionRiskAssessmentHeader.getDistributionRiskAssessmentHeader" result-class="com.paychex.hrs.riskassessment.entity.DistributionRiskAssessmentHeader">
<description>Get distribution risk assessment header data</description>
<query>
<![CDATA[
SELECT DR_DISTRIB_ID,
ED_PMT_METHOD,
ED_HOLD_FLAG,
DR_CREATED_DATE,
HH_ID,
DR_SSN,
ED_PAYEE_FIRST_NAME,
ED_PAYEE_LAST_NAME
FROM KIS.DISTRIBUTION_REQUESTS,
KIS.EMPLOYEE_DISTRIBUTIONS,
LNDRISK.HISTORY_HEADER,
HRIS.SEMPLOYEEPLAN,
HRIS.SEMPLOYEES
WHERE DR_DISTRIB_ID = :in_distribution_id`enter code here`
AND ED_DISTRIB_ID = DR_DISTRIB_ID
AND HH_DISBURSEMENT_ID = DR_DISTRIB_ID
AND ED_PLAN_ID = SEP_PLAN_ID
AND SEP_CLT_ID = SEE_CLT_ID
AND SEP_EMP_NBR = SEE_EMP_NBR
]]>
</query>
</named-native-query>
我相信这是因为您在用作SEmployees Id的类上使用@Id。 尝试将SEmployeesPK修改为:
public class SEmployeesPK implements Serializable {
private static final long serialVersionUID = 42L;
private Long seeCltId;
private Integer seeEmpNbr;
.
.
.
该错误一定是由于SEmployeesPK表不存在而导致的
希望这有帮助,祝你好运。如果你想为你的对象使用多个标识符,你应该使用@EmbeddedId 另外,@Embedded应该出现在类上,该类将通过@EmbeddedId注入 请参阅示例:
问题可能是由于外键或同义词而映射了不同的表(可能不存在或该表没有授予特权)
对我来说,问题在于该表中的一列与另一个架构表有映射,但它缺少.ex,public同义词。感谢您的回复。我试过你的建议,但没用。如果我将SEMPLOYEES表从ORM查询中取出,那么它就可以工作了。当我添加这个表和与这个表相关的条件时,它是和SEP\u CLT\u ID=SEE\u CLT\u ID和SEP\u EMP\u NBR=SEE\u EMP\u NBR。然后我得到了错误。不确定为什么??我建议改为这样做,这是我们在项目中的做法。一切都是正确的,但您是否使用@Embeddeble annotation?Moskura,我不是那个有问题的人。
public class SEmployeesPK implements Serializable {
private static final long serialVersionUID = 42L;
private Long seeCltId;
private Integer seeEmpNbr;
.
.
.