2013-05-20 67 views
1

我正在同時調用Oracle存儲過程主鍵空誤差的EclipseLink

異常說明如下錯誤:從該行讀取的主鍵[DatabaseRecord( RETVAL =>空 ERROR_MESSAGE =>空) ]在執行查詢期間被檢測爲空。主鍵 鍵不得包含空值。 查詢:ReadAllQuery(名稱= 「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,可以thiss錯誤,由於這樣做呢?

問候,

回答

0

它可能是一個的情況下的靈敏度的問題。嘗試使queryParameter屬性值都大寫,如:

@StoredProcedureParameter(queryParameter="PSUBNO",name="psubno",direction=Direction.IN), 

我在想,因爲數據庫列名(以及存儲過程的參數)默認大寫,如果你不使用Column指定的名稱註解。

+0

我根據你的建議做了改變,但仍然是相同的錯誤。 – ImranRazaKhan

0

你正在設置「resultClass = CcmAssignLoop.class」,這意味着程序將返回數據來構建這個類的實例,你的程序不會,所以不要設置它。然後,您將只獲取原始數據。