1

hibernate.hbm2ddl.auto を「create」に設定して、JPA を使用して Oracle テーブルを自動作成しようとしています。エンティティ フィールドの 1 つはブール型で、Java では次のようになります。

private boolean activateCustomer;

ただし、実行するとエラーがスローされ、エラーを見ると、生成された SQL 型は Number(1) ではなくブール型です。私は Hibernate 4.1.9 と Oracle XE (ファイル: OracleXE112_Win32.zip) を使用しています。

私がインターネットで見つけたもの(ほとんどが数年前のもの)から、デフォルトではNumber(1)である必要があります。動作を変更するために、Oracle、Hibernate、または JPA に変更はありましたか?

または、私が見逃した構成はありますか? ありがとう。


JPA 構成:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <properties>
        <property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect"/>
        <!-- value="create" to build a new database on each run; value="update" to modify an existing database; value="create-drop" means the same as "create" but also drops tables when Hibernate closes; value="validate" makes no changes to the database -->
        <property name="hibernate.hbm2ddl.auto" value="create"/>
        <property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy"/>
        <property name="hibernate.connection.charSet" value="UTF-8"/>
        <!-- Uncomment the following two properties for JBoss only -->
        <!-- property name="hibernate.validator.apply_to_ddl" value="false" /-->
        <!-- property name="hibernate.validator.autoregister_listeners" value="false" /-->
    </properties>
</persistence-unit>

4

2 に答える 2

2

11g を使用しているように見えるので、Oracle 8 専用ではorg.hibernate.dialect.Oracle10gDialectなく方言を使用する必要があります。org.hibernate.dialect.OracleDialect

于 2013-07-24T16:00:55.307 に答える
1

使ってみてください:

@Column(columnDefinition = "TINYINT")
@Type(type = "org.hibernate.type.NumericBooleanType")
private boolean activateCustomer;
于 2013-07-19T09:05:40.780 に答える