Hi all,
I have a question about using the hibernate object and stored procedure working together.
I have an object save session.save(order), then read the information from the stored procedure. I found that the "session.save(order)" is not really saved into the database until the "Transaction.commit();"
How can I solve this? Why I need to do this because, if the stored procedure validation fail, the "order" object will not be saved.
Code:
====
Session sess = new Session();
Order obj = new Order();
obj.setOrderNo("XXX");
sess.save(obj);
Connection conn = sess.connection();
query = "oracle_stored_procedure(?,?)";
CallableStatement callStmt = conn.prepareCall(query);
....
callStmt.execute();
....
if oracle_stored_procedure is return valid then
Transaction.commit();
else
Transaction.rollback();
end if;
oracle_stored_procedure:
=================
....
select * from order_table where order_no = "XXX";
...do something checking.....
Due to the sess.save(obj) is not really saved into the database, the "oracle_stored_procedure" cannot select the order. Always "rollback".
How can I solve this?
|