关于 getCurrentSession() 和 openSession()
Hibernate3.3+MySQL5.0+MyEclipse8.0 初学Hibernate 我把3.3的所有Jar包都导进去了
在使用openSession()获得Session对象时没出错,运行了;但用getCurrentSession();一直有异常如下:
Exception in thread "main" org.hibernate.HibernateException: No TransactionManagerLookup specified
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:503)
at com.bbll521.test.HibernateTest.add(HibernateTest.java:36)
at com.bbll521.test.HibernateTest.main(HibernateTest.java:24)
我的Hibernate.cfg.xml 配置文件如下:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>
<session-factory>
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="connection.url">
jdbc:mysql://127.0.0.1:3306/yhglxt
</property>
<property name="connection.username">root</property>
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="myeclipse.connection.profile">MySQL</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<mapping resource="com/bbll521/test/Information.hbm.xml" />
</session-factory>
</hibernate-configuration>
能帮我分析下吗? (给个getCurrentSession()成功例子,需要注意的地方,比如Hibernate配置上要注意什么)