我认为 hibernate.cfg.xml 和 hibernate.properties 实际上是等效的,因此可以互换使用。这是真的?
如果是这样,那么 hibernate.properties 中有时出现在 hibernate.cfg.xml 中的“映射”标记的等效属性名称是什么?
例如,这里是一个示例 hibernate.cfg.xml:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory
name="java:hibernate/SessionFactory">
<!-- properties -->
<property name="connection.datasource">java:/comp/env/jdbc/MyDB</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">false</property>
<property name="transaction.factory_class">
org.hibernate.transaction.JTATransactionFactory
</property>
<property name="jta.UserTransaction">java:comp/UserTransaction</property>
<!-- mapping files -->
<mapping resource="org/hibernate/auction/Item.hbm.xml"/>
<mapping resource="org/hibernate/auction/Bid.hbm.xml"/>
<!-- cache settings -->
<class-cache class="org.hibernate.auction.Item" usage="read-write"/>
<class-cache class="org.hibernate.auction.Bid" usage="read-only"/>
<collection-cache collection="org.hibernate.auction.Item.bids" usage="read-write"/>
</session-factory>
</hibernate-configuration>
我知道如何将这个 hibernate.cfg.xml 中的一些(但不是全部)标签转换为 hibernate.properties:
hibernate.connection.datasource=java:/comp/env/jdbc/MyDB
hibernate.dialect=org.hibernate.dialect.MySQLDialect
但是如何将其他标签(例如“mapping”)转换为 hibernate.properties?