如题,我在DAO 中加了事物, 我执行查询语句,未commit 会有其他隐患问题吗?
如果使用的是transaction scoped session那么提交事务就会导致关闭session
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbcracle:thin:scott/tiger@(description=(address_list=(address=(protocol=tcp)(host=host1)(port=1521)))(source_route=yes)(connect_data=(sid=Ora9i)(SERVICE_NAME = Ora9i)) )</property>
<property name="connection.username">scott</property>
<property name="connection.password">tiger</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">create</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hibernate.default_schema">scott</property>
<mapping resource="Emp.hbm.xml"/>
<!--mapping resource="test100.hbm.xml"-->
</session-factory>
其中<property name="current_session_context_class">thread</property>
hibernate session与当前线程绑定,当事务提交后,session也被关闭。