Reputation: 3805
I've got an Orcale DB with one procedure called Save
. And this is how I run it:
> EXECUTE DBManager.Save;
And now I want to do the same using Hibernate.
public void save() {
Session session = null;
session = this.sessionFactory.getCurrentSession();
Query query = session.createSQLQuery("EXECUTE DBManager.Save;");
int updated = query.executeUpdate();
}
This code doesn't work.
WARN : org.hibernate.util.JDBCExceptionReporter - SQL Error: 900, SQLState: 42000
What do?
Upvotes: 0
Views: 258
Reputation: 658
Try like this example
Query query = session.createSQLQuery( "CALL GetStocks(:stockCode)") .addEntity(Stock.class) .setParameter("stockCode", "7277");
Upvotes: 2
Reputation: 44834
For Oracle you can use code like
CallableStatement cs = null;
cs = this.con.prepareCall("{call DBManager.Save}");
ResultSet rs = cs.executeQuery();
Upvotes: 1