任何帮助或提示将不胜感激!! 我收到找不到存储过程名称的错误。
在线查看并在stackoverflow中遇到相同的问题,但解决方法是不使用命名存储过程。
@SuppressWarnings("unchecked")
public List<WebServiceUserResult> findAll(String userName, String password) {
final StoredProcedureQuery storedProcedureQuery = getEntityManager.createNamedStoredProcedureQuery(WebServiceUserResult.NamedQuery);
return storedProcedureQuery.getResultList();
}
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.ColumnResult;
import javax.persistence.ConstructorResult;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedStoredProcedureQuery;
import javax.persistence.ParameterMode;
import javax.persistence.SqlResultSetMapping;
import javax.persistence.StoredProcedureParameter;
import ca.mychart.hub.entity.mybook.MedScheduleResult;
@NamedStoredProcedureQuery(name = WebServiceUserResult.NamedQuery, procedureName = "p_webServicesUser", resultSetMappings = "scheduleNameMapping", parameters = {
@StoredProcedureParameter(name="userName", type=String.class, mode=ParameterMode.IN),
@StoredProcedureParameter(name="password", type=String.class, mode=ParameterMode.IN)})
@SqlResultSetMapping(name = "scheduleNameMapping", classes = { @ConstructorResult(targetClass = MedScheduleResult.class, columns = {
@ColumnResult(name = "ID", type = Integer.class),
@ColumnResult(name = "isActive", type = Integer.class),
@ColumnResult(name = "siteId", type = Integer.class)
})
})
@Entity
public class WebServiceUserResult implements Serializable {
private static final long serialVersionUID = -15665963010799315L;
public static final String NamedQuery = "webServicesUserSP";
@Id
@Column
private Integer ID;
@Id
@Column
private Integer isActive;
@Id
@Column
private Integer siteId;
public Integer getID() {
return ID;
}
public void setID(Integer iD) {
ID = iD;
}
public Integer getIsActive() {
return isActive;
}
public void setIsActive(Integer isActive) {
this.isActive = isActive;
}
public Integer getSiteId() {
return siteId;
}
public void setSiteId(Integer siteId) {
this.siteId = siteId;
}
public WebServiceUserResult() {
this.ID = 0;
this.isActive = 0;
this.siteId = 0;
}
public WebServiceUserResult(Integer ID, Integer isActive, Integer siteId) {
this.ID = ID;
this.isActive = isActive;
this.siteId = siteId;
}
}
我期望它能够调用存储过程并为我提供结果。但是相反,我得到了以下错误:
未找到具有该名称的@NamedStoredProcedureQuery: