我正在尝试从hibernate执行存储过程。我是hibernate的新手,如果我的代码中有任何错误,请告诉我。
映射hbm文件
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<sql-query name="callcopyDocumentStoredProcedure">
<return alias="document" class="com.common.Document" />
[exec copyDocument (:param1, :param2, :param3, :param4, :param5 ,:param6 ,:param7)]
</sql-query>
</hibernate-mapping>
我正在执行的代码
Query copy= session.getNamedQuery("callcopyDocumentStoredProcedure");
copy.setParameter("param1", 1234);
copy.setParameter("param2", 12);
copy.setParameter("param3", 12);
copy.setParameter("param4", 0);
copy.setParameter("param5", 0);
copy.setParameter("param6", 1);
copy.setParameter("param7", 12);
List result = copy.list();
for(int i=0; i<result.size(); i++){
Document newDocument = (Document)result.get(i);
System.out.println(newDocument.getId());
}
它出了什么问题?
答案 0 :(得分:0)
sp call的正确语法是{call copyDocument (:param1, :param2, :param3, :param4, :param5 ,:param6 ,:param7)}
作为描述符here