我有这个代码:
SessionFactory sessionFactory = new Configuration().configure("hibernate.cfg.xml");
我如何将其配置为 bean?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">
<hibernate-configuration>
<session-factory name="sessionFactory">
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.password">scott</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@x.x:1521:x</property>
<property name="hibernate.connection.username">scott</property>
<property name="hibernate.default_schema">SCOTT</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.search.autoregister_listeners">false</property>
<mapping resource="ormbyxml/domain/Emp.hbm.xml" />
<mapping resource="ormbyxml/domain/SalaryLog.hbm.xml" />
<mapping resource="ormbyxml/domain/Dept.hbm.xml" />
<mapping resource="ormbyxml/domain/Salgrade.hbm.xml" />
<mapping resource="ormbyxml/domain/Bonus.hbm.xml" />
</session-factory>
</hibernate-configuration>