0
私はHibernateをサポートするサンプルのmavenプロジェクトを持っています。問題は:Hibernateはデータベースにテーブルを作成しません。スタックオーバーフローに関する同様の質問の回答は、hibernate.hbm2ddl.autoに "create"を設定することを示唆していますが、動作しません。Hibernateはテーブルを作成しません
私はhibernate.cfg.xml:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://www.hibernate.org/dtd/hibernate-configuration-..">
<hibernate-configuration>
<session-factory>
<property name="connection.url">jdbc:mysql://localhost:3306/hibernate_test</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.username">user</property>
<property name="connection.password">password</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
<property name="show_sql">true</property>
<property name="hibernate.hbm2ddl.auto">create</property>
<mapping class="Person"></mapping>
</session_factory>
</hibernate-configuration>
Entityクラス:
@Entity
@Table(name = "person")
public class Person implements Serializable {
private static final long serialVersionUID = Long.MIN_VALUE;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column
private Long id;
@Column
private String firstName;
//getters/setters etc.
実行は、次の行で停止:私が間違っているの
INFO: HHH000115: Hibernate connection pool size: 20 (min=1)
Sep 06, 2016 10:56:57 AM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
Sep 06, 2016 10:56:57 AM org.hibernate.tool.schema.internal.SchemaCreatorImpl applyImportSources
INFO: HHH000476: Executing import script 'org.hibernate.tool.schema.i[email protected]'
何?
DBには既にテーブルが含まれていますか?そうであれば、ログにドロップテーブルステートメントを印刷していますか? –
いいえ、データベースにテーブルがなく、 "ドロップ"や "作成"などのログはありません。 – Troir1
あなたのソリューションは何ですか? – RY35