【发布时间】:2013-05-20 15:27:36
【问题描述】:
我在调用 oracle 存储过程时遇到以下错误
异常说明:从行[DatabaseRecord( retval => null error_message => null)] 在执行查询期间被检测为 null。基本的 键不能包含 null。 查询:ReadAllQuery(name="CCM_ASSIGN_LOOP" referenceClass=CcmAssignLoop )
我的实体是
@Entity
@NamedStoredProcedureQuery(name="CCM_ASSIGN_LOOP", procedureName="TCS.CCM_ASSIGN_LOOP", resultClass=CcmAssignLoop.class,
parameters={
@StoredProcedureParameter(queryParameter="psubno",name="psubno",direction=Direction.IN),
@StoredProcedureParameter(queryParameter="upd_user",name="upd_user",direction=Direction.IN),
@StoredProcedureParameter(queryParameter="ccloop_in",name="ccloop_in",direction=Direction.IN),
@StoredProcedureParameter(queryParameter="ccstage_in",name="ccstage_in",direction=Direction.IN),
@StoredProcedureParameter(queryParameter="retval",name="retval",direction=Direction.OUT),
@StoredProcedureParameter(queryParameter="error_message",name="error_message",direction=Direction.OUT)
}
)
public class CcmAssignLoop implements Serializable {
private static final long serialVersionUID = 1L;
public CcmAssignLoop() {
super();
}
@Id
private String psubno;
private String upd_user;
private String ccloop_in;
private BigDecimal ccstage_in;
private String retval;
private String error_message;
public String getPsubno() {
return psubno;
}
public void setPsubno(String psubno) {
this.psubno = psubno;
}
public String getUpd_user() {
return upd_user;
}
public void setUpd_user(String upd_user) {
this.upd_user = upd_user;
}
public String getCcloop_in() {
return ccloop_in;
}
public void setCcloop_in(String ccloop_in) {
this.ccloop_in = ccloop_in;
}
public BigDecimal getCcstage_in() {
return ccstage_in;
}
public void setCcstage_in(BigDecimal ccstage_in) {
this.ccstage_in = ccstage_in;
}
public String getRetval() {
return retval;
}
public void setRetval(String retval) {
this.retval = retval;
}
public String getError_message() {
return error_message;
}
public void setError_message(String error_message) {
this.error_message = error_message;
}
}
下面是调用存储过程的代码
Query q = tabsEm.createNamedQuery("CCM_ASSIGN_LOOP");
q.setParameter("psubno", subno);
q.setParameter("upd_user", "abc");
q.setParameter("ccloop_in", "xyz");
q.setParameter("ccstage_in", new BigDecimal(5));
// CcmAssignLoop ccmAssignLoop = (CcmAssignLoop)q.getSingleResult();
q.getResultList();
上述列不是主键,我收到此错误。
更新:
我在 oracle 上的程序开始像
CREATE OR REPLACE PROCEDURE TCS.CCM_ASSIGN_LOOP(PSUBNO IN VARCHAR2, UPD_USER IN VARCHAR2, CCLOOP_IN IN VARCHAR2, CCSTAGE_IN IN NUMBER, RETVAL OUT VARCHAR2, ERROR_MESSAGE OUT VARCHAR2)
IS
OLD_CCSTAGE CCM_USER_INFO.CCLOOP_STAGE%TYPE;
OLD_CCLOOP CCM_USER_INFO.CCLOOP%TYPE;
PROC_CONTRNO CRM_USER_INFO.CONTRNO%TYPE;
TEMP_COUNT NUMBER;
RET_VAL VARCHAR2(100);
V_ERROR_MESSAGE VARCHAR2(256);
我可以看到 RETVAL 和 RET_VAL,这可能是因为这个错误吗?
问候,
【问题讨论】:
标签: java jpa eclipselink