How to call a stored procedure using a HibernateTemplate within spring?

Can someone help me call a stored procedure using a HibernateTemplate within spring? I am new to Hibernate, so please help me with this.

Thanks in advance,

Cinu Matthews

+3
source share
2 answers

In Hibernate, stored procedures are just a special case of named query , and you execute named queries HibernateTemplateusing one of the following findByNamedQuery().

+1
source

HibernateTemplate , getCurrentSession() SessionFactory getSession HibernateTemplate.

findByNameQuery(), , , - .

,

java.sql.Connection con = getSession().connection;<br>
CallableStatement statement = con.prepareCall(<your procedure>);<br>
//some setting parameter for your procedure<br>
statement.execute();
0

Source: https://habr.com/ru/post/1745401/


All Articles