Hibernate calls the Oracle Stored Procedure

Source: Internet
Author: User

We only need to bypass hibernate to call the jdbc API. Of course, the transaction is managed by the hibernate industry:
Assume that the following stored procedure is created:

Create or replace procedure batchUpdateCustomer (p_age in number)
Begin
Update MERs set AGE = AGE + 1 where AGE> p_age;
End;

There is a parameter p_age In the stored procedure, which indicates the customer's age. The application can call the stored procedure as follows:
Code content
Tx = session. beginTransaction ();
Connection con = session. connection ();
String procedure = "{call batchUpdateCustomer (?) }";
CallableStatement cstmt = con. prepareCall (procedure );
Cstmt. setInt (); // set the age parameter to 0.
Cstmt.exe cuteUpdate ();
Tx. commit ();

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.