使用session.doWork
时出现以下错误,此处是我的代码
@Override
public void linkDeliveryToRack(Session session, final Delivery delivery, final Rack rack) {
session.doWork(new Work() {
@Override
public void execute(Connection connection) throws SQLException {
PreparedStatement st = connection.prepareStatement("call P_LINK_DELIVERY_TO_RACK (?,?)");
st.setInt(1, delivery.getIdDelivery());
st.setInt(2, rack.getIdRack());
st.execute();
st.close();
}
});
}
我收到错误:
警告 - SQL错误:-11,SQLState:37000错误 - 意外的令牌: P_LINK_DELIVERY_TO_RACK在声明中[致电P_LINK_DELIVERY_TO_RACK (?,?)] org.hibernate.exception.SQLGrammarException:执行错误的工作 org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92) 在 org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) 在 org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52) 在org.hibernate.impl.SessionImpl.doWork(SessionImpl.java:2001)at com.saintgobain.ramses.lib.dao.link.impl.LinkActionProcedureDaoImpl.linkDeliveryToRack(LinkActionProcedureDaoImpl.java:19) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在java.lang.reflect.Method.invoke(Method.java:497)at junit.framework.TestCase.runTest(TestCase.java:168)at junit.framework.TestCase.runBare(TestCase.java:134)at junit.framework.TestResult $ 1.protect(TestResult.java:110)at junit.framework.TestResult.runProtected(TestResult.java:128)at at junit.framework.TestResult.run(TestResult.java:113)at junit.framework.TestCase.run(TestCase.java:124)at junit.framework.TestSuite.runTest(TestSuite.java:243)at junit.framework.TestSuite.run(TestSuite.java:238)at 引起:java.sql.SQLException:意外的令牌: P_LINK_DELIVERY_TO_RACK在声明中[致电P_LINK_DELIVERY_TO_RACK (?,?)] org.hsqldb.jdbc.Util.throwError(未知来源)at at org.hsqldb.jdbc.jdbcPreparedStatement。(未知来源)at org.hsqldb.jdbc.jdbcConnection.prepareStatement(未知来源)at com.saintgobain.ramses.lib.dao.link.impl.LinkActionProcedureDaoImpl $ 1.execute(LinkActionProcedureDaoImpl.java:23) 在org.hibernate.impl.SessionImpl.doWork(SessionImpl.java:1997)
存储过程: P_LINK_DELIVERY_TO_RACK
create or replace
PROCEDURE P_LINK_DELIVERY_TO_RACK (p_delivery_id IN NUMBER, p_rack_id IN NUMBER)
IS
v_count_existing_link NUMBER;
v_truck_id NUMBER;
CURSOR c_order_items
IS
SELECT id_order_item, quantity
FROM order_item
WHERE delivery_id = p_delivery_id;
BEGIN
SELECT TRUCK_ID
INTO v_truck_id
FROM rack
WHERE id_rack = p_rack_id;
FOR order_item_row IN c_order_items
LOOP
SELECT COUNT (0)
INTO v_count_existing_link
FROM order_item_link
WHERE order_item_id = order_item_row.id_order_item
AND rack_id = p_rack_id;
IF (v_count_existing_link > 0)
THEN
UPDATE order_item_link
SET truck_id = v_truck_id,
quantity_rack = order_item_row.quantity,
date_association = SYSDATE,
current_flag = 1
WHERE order_item_id = order_item_row.id_order_item
AND rack_id = p_rack_id;
ELSE
INSERT INTO order_item_link
VALUES (order_item_link_seq.NEXTVAL,
order_item_row.id_order_item,
p_rack_id,
v_truck_id,
order_item_row.quantity,
SYSDATE,
1);
END IF;
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
NULL;
WHEN OTHERS
THEN
-- Consider logging the error and then re-raise
RAISE;
END P_LINK_DELIVERY_TO_RACK;
我在 sqldeveloper 中执行的存储过程,它使用虚拟数据工作:
execute P_LINK_DELIVERY_TO_RACK(2,1);
但不知道为什么我收到错误Caused by: java.sql.SQLException: Unexpected token: P_LINK_DELIVERY_TO_RACK in statement [call P_LINK_DELIVERY_TO_RACK (?,?)]
请帮帮我。