hibernate 调用oracle自定义函数方法一

阅读更多
1,首先编写自定义函数:
create or replace function getSum(a number,b number) return number is
begin
          return a+b;
end;


2,ssh调用上卖弄的函数
//hql调用存储过程
 public void testHqlSelect6(){
    	 Session session = sessionFactory.openSession();
    	 Transaction ta = session.beginTransaction();
    	 String hql = "select getSum(:a,:b) from dual";
    	 List moneys = session.createSQLQuery(hql).setString("a", "3").setString("b", "4").list();
    	 for(int i=0; i 
 

3,输出结果:
Hibernate: select getSum(?,?) from dual
7

你可能感兴趣的:(hibernate,oracle函数)