【发布时间】:2018-01-14 11:55:44
【问题描述】:
我正在创建会话工厂对象,如下所示:
SessionFactory factory = new Configuration().configure().buildSessionFactory();
哪个类提到了我在 *.hbm.xml 文件中提到的数据库?
【问题讨论】:
标签: database hibernate sessionfactory
我正在创建会话工厂对象,如下所示:
SessionFactory factory = new Configuration().configure().buildSessionFactory();
哪个类提到了我在 *.hbm.xml 文件中提到的数据库?
【问题讨论】:
标签: database hibernate sessionfactory
要使用的数据库在 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 的东西有时可能已经过时,但那个该死的家伙几乎单枪匹马地负责我目前的工作。)
【讨论】: