Datanucleus autoCreateSchema问题(矛盾的错误消息)

时间:2012-03-23 13:49:37

标签: java h2 jdo datanucleus

我有一个小的本地H2数据库,其内容已使用DataNucleus'创建。 JDO实现。它包含一个rawcontainitem表,与以下对象关联:

@PersistenceCapable(objectIdClass=RawItemKey.class)
@Index(name="CONTAIN_IDX", members={"prefix", "language", "value"})
public class RawContainItem {

    @PrimaryKey
    @Column(length=40)
    String prefix = "";

    @PrimaryKey
    @Column(length=2)
    String language = "";

    @PrimaryKey
    @Column(length=Integer.MAX_VALUE)
    String value = "";    

    public RawContainItem(String prefix, String language, String value) {

        this.prefix = prefix;
        this.language = language;
        this.value = value;

    }

}

此表目前包含多行language="FR"。我想用language="EN"添加更多行,但是我收到了奇怪的错误消息。

datanucleus.autoCreateSchema设置为true时,我得到:

INFO: Managing Persistence of Class : net.dwst.findword.DataNucleus.RawContainItem [Table : RAWCONTAINITEM, InheritanceStrategy : new-table]
23-mars-2012 14:42:49 org.datanucleus.store.rdbms.table.AbstractTable create
INFO: Creating table RAWCONTAINITEM
23-mars-2012 14:42:50 org.datanucleus.store.rdbms.table.AbstractTable executeDdlStatementList
GRAVE: Error thrown executing CREATE TABLE RAWCONTAINITEM
(
    "LANGUAGE" VARCHAR(2) NOT NULL,
    PREFIX VARCHAR(40) NOT NULL,
    "VALUE" VARCHAR(2147483647) NOT NULL,
    CONSTRAINT RAWCONTAINITEM_PK PRIMARY KEY ("LANGUAGE",PREFIX,"VALUE")
) : Table "RAWCONTAINITEM" already exists; SQL statement:
CREATE TABLE RAWCONTAINITEM
(
    "LANGUAGE" VARCHAR(2) NOT NULL,
    PREFIX VARCHAR(40) NOT NULL,
    "VALUE" VARCHAR(2147483647) NOT NULL,
    CONSTRAINT RAWCONTAINITEM_PK PRIMARY KEY ("LANGUAGE",PREFIX,"VALUE")
) [42101-164]
org.h2.jdbc.JdbcSQLException: Table "RAWCONTAINITEM" already exists;
...

此消息为真,表确实存在。

datanucleus.autoCreateSchema设置为false时,我得到:

Required table missing : "RAWCONTAINITEM" in Catalog "" Schema "".
DataNucleus requires this table to perform its persistence operations.
Either your MetaData is incorrect, or you need to enable "datanucleus.autoCreateTables"
org.datanucleus.store.rdbms.exceptions.MissingTableException:
Required table missing : "RAWCONTAINITEM" in Catalog "" Schema "".
DataNucleus requires this table to perform its persistence operations.
Either your MetaData is incorrect, or you need to enable "datanucleus.autoCreateTables"
...

但是表确实存在......什么给出了?

0 个答案:

没有答案