我是java和hibernate框架的新手,请问我是否必须为我拥有的每个表制作一个Hibernate cfg文件,或者仅此就足够了。现在我有了这个,它可以处理一个人表,现在,如果我还想使用一个新表(以我的情况为例),是否需要编写一个新文件并更改映射?
<?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">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3310/scheduler</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">blanked-out-as-this-is-s3cr3t</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">update</property>
<mapping class="com.scheduler.backend.model.Person"></mapping>
</session-factory>
</hibernate-configuration>
答案 0 :(得分:0)
您只需要一个 cfg文件,如果您需要添加新表,只需将其发布为
class Event_Class {
Flag_Play;
Flag_Pause;
Flag_Stop;
Initialize() {
this.Flag_Play = false;
this.Flag_Pause = false;
this.Flag_Stop = false;
}
Play() {
this.Flag_Play = true;
this.Flag_Pause = false;
this.Flag_Stop = false;
}
Pause() {
this.Flag_Play = false;
this.Flag_Pause = true;
this.Flag_Stop = false;
}
Stop(Simulation, PMSM) {
this.Flag_Play = false;
this.Flag_Pause = false;
this.Flag_Stop = true;
Simulation.Initialize();
PMSM.Initialize();
}
}
因此文件应如下所示:
<mapping class="com.scheduler.backend.model.NEW_MODEL"></mapping>