我正在创建Session工厂对象,如下所示:
SessionFactory factory = new Configuration().configure().buildSessionFactory();
哪个类提到了我在* .hbm.xml文件中提到的数据库?
答案 0 :(得分:0)
要使用的数据库在hibernate.cfg.xml文件中定义。在此文件中,您可以定义数据库连接统计信息以及映射要使用的类(如果您这样选择)。此处的连接统计信息示例如下:
hibernate.cfg.xml form this tutorial:
<?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>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@127.0.0.1:1521:MKYONG</property>
<property name="hibernate.connection.username">mkyong</property>
<property name="hibernate.connection.password">password</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.default_schema">MKYONG</property>
</session-factory>
</hibernate-configuration>
同样值得注意:Configuration - Hibernate Documentation
(旁注:mkyong的东西有时候可能已经过时了,但那个单身附近的家伙是我现在要保住工作的原因。)