public int updateCpnstWS(String serviceNo, String ifTemp, String ifLast,String bizFlag) {
System.out.println("Call Mathod : updateCpnstWS");
Session session = HibernateSessionFactory.getSession();
Transaction trans = session.beginTransaction();
try {
TcpnsthistoryDAO tdao = new TcpnsthistoryDAO();
Tcpnsthistory th = tdao.findById(Long.parseLong(serviceNo));
到这里 包空指针------》th.setIfTemp(Long.parseLong(ifTemp));
th.setIfLast(Long.parseLong(ifLast));
th.setBizFlag(Long.parseLong(bizFlag));
这里是什么意思 -----》 tdao.merge(th);
trans.commit();
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
trans.rollback();
return -1;
} 还要麻烦下大侠们merge()的用法,还有上面代码使用的意义,谢谢啦!
return 1;
}

解决方案 »

  1.   

    我认为:ifTemp传过来的是null,就空指针,就不能在parseLong()了;
    关于merge()的使用,要对Hibernate的对象的三种状态之间的相互关系理清楚,详见:http://huangtut.javaeye.com/blog/261520
      

  2.   

    merge是返回自由态的saveorupdate。在往深研究这个理解可能是错的。
    --------------------------------------------------------------------------
    Tcpnsthistory th= tdao.findById(Long.parseLong(serviceNo)); ;
    if(th==null){
      th=new Tcpnsthistory ();
    }
      

  3.   

    这代码,怎么dao中还调用别的dao呢