posts - 84,  comments - 54,  trackbacks - 0
回调,有什么好处呢,是一种设计模式吗?
只是在hibernate当中的template当中会使用到。例如以下:

  1. public int executeUpdate(final String hql, final Map pMap) {  
  2.         int result = 0;  
  3.         Object o = getHibernateTemplate().execute(new HibernateCallback() {  
  4.           //实现HibernateCall接口当中的方法,自己实现接口当中的方法的
  5.          //具体业务流程
  6.             public Object doInHibernate(final Session session)  
  7.                     throws HibernateException {  
  8.                     int result = 0;  
  9.                      Query queryObject = session.createQuery(hql);  
  10.                      String[] params = queryObject.getNamedParameters();  
  11.                      
  12.                        for (int i = 0, max = params.length; i < max; i++) {  
  13.                             queryObject.setParameter(params[i], pMap.get(params[i]));  
  14.                       }  
  15.                      
  16.                         result = queryObject.executeUpdate();  
  17.                         return result;  
  18.               }  
  19.         });  //end of method execute()
  20.        
  21.         Integer i = (Integer) o;  
  22.         result = i.intValue();  
  23.         return result;  
  24.     } 

   使用hibernate模板类当中的方法。
。。。。。。。。。未完待续。

posted on 2009-05-19 17:21 JavaCoffe 阅读(148) 评论(0)  编辑  收藏 所属分类: J2SE基础学习

只有注册用户登录后才能发表评论。


网站导航:
 
<2009年5月>
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

常用链接

留言簿(5)

随笔分类(80)

收藏夹(1)

最新随笔

积分与排名

  • 积分 - 56797
  • 排名 - 900

最新评论

阅读排行榜