Hibernate calls to Oracle stored procedures

Source: Internet
Author: User

Because each device collects GPS data, it is decided to implement the sub-table. The original thought is to use JDBC to achieve, but there will always be unexpected things happen, it is depressed (such as the summary of the problem). So after thinking still put this SQL operation thing to the stored procedure to do it.

There are two ways to implement a stored procedure call using Hibernate:

1. JDBC Call:

Session session =hibernatesessionfactory.getsession ();   Connection conn = Session.connection ();  ResultSet RS =null;  CallableStatement call = Conn.preparecall ("{Call proc (?)}");     Call.setstring (1, parameter);  rs = Call.executequery ();  Rs.close (); Session.close ();

2. Hibernate sqlquery:

Session session =hibernatesessionfactory.getsession (); SQLQuery query = Session.createsqlquery ("{Call Tj (?)}"); This calls the stored procedure query.setstring (0, "ddd");  List List =query.list (); Session.close ();


Hibernate calls to Oracle stored procedures

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.