我的网络服务有一个大问题,我有一个返回游标的过程。但是在那个游标中,我还有一个类型为游标的列,因此我如何为我的实体类定义此列。我正在使用@NamedStoredProcedureQuery
注释。当我尝试在Web服务中运行该proc时,返回->
java.sql.SQLException: Invalid column name
感谢您的帮助。
答案 0 :(得分:0)
// This stored procedure returns a cursor output parameter, and has one input parameter.
@NamedStoredProcedureQuery(
name = "ReadAddressById",
resultClasses = Address.class,
procedureName = "READ_ADDRESS",
parameters = {
@StoredProcedureParameter(mode=IN, name="P_ADDRESS_ID", type=Long.class),
@StoredProcedureParameter(mode=REF_CURSOR, name="CUR_ADDRESS", type=void.class)
}
)
@Entity
public class Address {
...
}
//Example calling a named stored procedure with a cursor output parameter
StoredProcedureQuery query = em.createNamedStoredProcedureQuery("ReadAddressById");
query.setParameter("P_ADDRESS_ID", 12345);
query.execute();
List<Address> result = (List<Address>)query.getOutputParameterValue("CUR_ADDRESS");