Hibernate 最简单例子 (14)

    privatestatic Logger log =Logger.getLogger(DemoHibernateTest.class);

 

    /**

     *@paramargs

     */

    publicstaticvoid main(String[] args) {

       // TODO Auto-generated method stub

         log.debug("------测试!----");

       //addUser();

       listUser();

       changeUser();

    }

//省略

}

运行就会在Console输出log,选中工程DemoHibernate刷新就会看到HibernateDemoLog.log 内容如下(节选):

2007-06-16 11:25:33 [com.guoqiang.hibernate.DemoHibernateTest]-[DEBUG] ------测试!---- -(:14)

//省略

2007-06-16 11:41:31 [org.hibernate.impl.SessionImpl]-[DEBUG] after transaction completion -(:417)

Pringting Updated User, User[Username: test, Password:test,First Name: demo,Last Name: demo]//输出内容!!!!

2007-06-16 11:41:31 [org.hibernate.impl.SessionImpl]-[DEBUG] closing session -(:268)

2007-06-16 11:41:31 [org.hibernate.jdbc.ConnectionManager]-[DEBUG] connection already null in cleanup : no action -(:369)

 

参考资料

1 Introduction to Hibernate Tutorial

2 《最简单的Log4j使用》

3 First Hibernate example

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zzjzyw.html