为什么hbm文件中的数据库名称会覆盖hibernate配置文件中的数据库名称

为什么hbm文件中的数据库名称会覆盖hibernate配置文件中的数据库名称,hibernate,Hibernate,在hibernate配置文件中,我用来指定包括数据库名称在内的属性 <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernat

在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/test</property>
在其中一个hbm文件中

<class name="com.test.entity.User" table="user" catalog="employee">
为什么hbm文件中的目录会覆盖到hibernate配置文件hibernate中指定的数据库的连接


它是否连接到两个数据库?

实体级配置将覆盖默认配置,因为您可能希望大多数实体都有一个默认目录,而只有少数实体应用于不同的目录

无论如何,全局目录设置为:

<prop key="hibernate.default_catalog">employee</prop>
但是在MySql中,在JDBCURL中的数据库名称和数据库目录对象之间

在您的示例中,用户实体将使用员工目录,而不是测试目录