hibernate 工作的实现原理步骤

step1:创建Configuration:进行配置文件的装载操作,提取所有配置文件进行解析。

step2:创建SessionFactory对象:托尼各国创建好的Configurtation对象可以创建一个sessionFactory对象的实例,他是产生Session对象实例的工厂,它在整个应用中应该是唯一的。

step2:创建Session对象:Session对象类似于数据库的连接对象,可以理解为于数据库建立的一个连接,但他的功能比JDBC重的Connection的对象丰富很多。

step4开始一个事物  在Java中定义一个事物操作的开始,这是使用Hibernate进行持久化操作必不可少的步骤。

step5 进行持久化操作,在这个步骤中可以读取或者保存java对象。

step6 结束事物 显示的结束事物

step 7关不Session ,类似于释放数据库的连接。

 

示例:STEP1:6:34:23,890 DEBUG TransactionInterceptor:363 - Getting transaction for [com.hongwei.athena.service.OrganizationService.findUpperOrgsByUserId]

STEP2:16:34:23,890 DEBUG TransactionSynchronizationManager:139 - Retrieved value [org.springframework.orm.hibernate3.SessionHolder@1d78908] for key [org.hibernate.impl.SessionFactoryImpl@18e2044] bound to thread [http-8080-8]

STEP3:16:34:23,921 DEBUG AbstractBatcher:410

 

6:34:23,953 DEBUG TransactionInterceptor:392

16:34:23,968 DEBUG JDBCTransaction:134 - commit
16:34:23,984 DEBUG JDBCTransaction:227 - re-enabling autocommit

 

 

16:34:26,562 DEBUG JDBCTransaction:147 - committed JDBC Connection
16:34:26,562 DEBUG ConnectionManager:325 - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
16:34:26,562 DEBUG HibernateTransactionManager:964 - Triggering afterCommit synchronization
16:34:26,562 DEBUG HibernateTransactionManager:980 - Triggering afterCompletion synchronization
16:34:26,562 DEBUG TransactionSynchronizationManager:311 - Clearing transaction synchronization
16:34:26,562 DEBUG DataSourceUtils:202 - Resetting read-only flag of JDBC Connection [10383317(com.mysql.jdbc.JDBC4Connection@166fec0)]
16:34:26,562 DEBUG HibernateTransactionManager:741 - Not closing pre-bound Hibernate Session [org.hibernate.impl.SessionImpl@1304435] after transaction
16:34:26,562 DEBUG SessionImpl:401 - disconnecting session
16:34:26,562 DEBUG ConnectionManager:464 - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
16:34:26,578 DEBUG ConnectionManager:325 - transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
16:34:26,578 DEBUG DefaultActionInvocation:57 - No result returned for action com.hongwei.athena.web.action.reminder.ReminderAction at null
16:34:26,578 DEBUG I18nInterceptor:57 - after Locale=zh
16:34:26,578 DEBUG I18nInterceptor:57 - intercept }
16:34:26,578 DEBUG ActionContextCleanUp:57 - skipping cleanup counter=1
16:34:26,578 DEBUG TransactionSynchronizationManager:229 - Removed value [org.springframework.orm.hibernate3.SessionHolder@9dc7a4] for key [org.hibernate.impl.SessionFactoryImpl@18e2044] from thread [http-8080-1]
16:34:26,578 DEBUG OpenSessionInViewFilter:207 - Closing single Hibernate Session in OpenSessionInViewFilter
16:34:26,578 DEBUG SessionFactoryUtils:784 - Closing Hibernate Session

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值