Postgresql:使用Hibernate通过Java代码调用存储过程
使用lambda表达式(->{)调用存储过程时出错 错误:org.postgresql.util.PSQLException:错误:在“{”处或附近出现语法错误 下面是我使用Prepared调用存储过程的代码 声明 我想执行此存储过程。请您建议更改或修改我的当前代码来帮助我 提前感谢。试试这个:Postgresql:使用Hibernate通过Java代码调用存储过程,java,postgresql,hibernate,stored-procedures,Java,Postgresql,Hibernate,Stored Procedures,使用lambda表达式(->{)调用存储过程时出错 错误:org.postgresql.util.PSQLException:错误:在“{”处或附近出现语法错误 下面是我使用Prepared调用存储过程的代码 声明 我想执行此存储过程。请您建议更改或修改我的当前代码来帮助我 提前感谢。试试这个: public void deleteData(Session session, int minVal, int maxVal) throws SQLException { session.doW
public void deleteData(Session session, int minVal, int maxVal) throws SQLException {
session.doWork(new Work() {
@Override
public void execute(Connection connection) throws SQLException {
CallableStatement st = null;
st = connection.prepareCall("{call delete_data(?,?)}");
st.setInt(1, minVal);
st.setInt(2, maxVal);
st.execute();
st.close();
}
});
}
public void deleteData(Session session, int minVal, int maxVal) throws SQLException {
session.doWork(new Work() {
@Override
public void execute(Connection connection) throws SQLException {
CallableStatement st = null;
st = connection.prepareCall("{call delete_data(?,?)}");
st.setInt(1, minVal);
st.setInt(2, maxVal);
st.execute();
st.close();
}
});
}