2013-09-16 48 views
0

有没有人知道hibernate配置文件(hibernate.cfg.xml),什么是“连接”属性 - 没有“hibernate”前缀 - 用于?休眠连接配置的前缀?

我的意思是,为什么这些属性(如connection.url,connection.usermame ...)存在?

<hibernate-configuration> 
    <session-factory> 
     <property name="connection.driver_class">org.postgresql.Driver</property> 
     ... 
     <property name="connection.url">SOME_URL</property> 
     <property name="hibernate.connection.url">SOME_URL</property> 
     <property name="connection.username">SOME_USER</property> 
     <property name="hibernate.connection.username">SOME_USER</property> 
    ... 

为什么我可以使用connection.url和hibernate.connection.url?

答:

好吧,我相信这些属性(不休眠的前缀。)只存在与旧版本的Hibernate的配置文件的向后兼容性。

谢谢。

回答

0

hibernate.connection.url用于连接数据库url以下是hibernate的配置设置。希望它会帮助你。

<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> 
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> 
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/youdb</property> 
<property name="hibernate.connection.username">user</property> 
<property name="hibernate.connection.password">password</property> 
<property name="hibernate.hbm2ddl.auto">update</property> 
<property name="hibernate.show_sql">true</property> 
<mapping resource="emp/dto/Employee.hbm.xml"/> 
+0

是的,我知道。谢谢。问题是 - 为什么connection.url,connection.username,connection.password(没有hibernate.prefix)也存在? – AlonL