Eclipse Glassfish 3.1 适配器 - SEQUENCE 已存在错误

发布于 2024-12-11 05:29:12 字数 1525 浏览 0 评论 0原文

我在使用 Glassfish 3.1 的 Eclipse 服务器适配器时遇到一些问题。我正在使用 JPA 自动生成的标识符。如果服务器正在运行并且我有 JPA 的创建和删除策略,那么每次发生热重新部署时,我都会收到一条巨大的 Eclipse 错误消息:

无法部署 MyWebApp 模块部署错误:MyWebApp:

PER01003:部署遇到 SQL 异常: PER01000:执行语句“CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL,SEQ_COUNT DECIMAL(38),主键 (SEQ_NAME))":

org.postgresql.util.PSQLException:错误:关系“序列”已存在

我知道这只是一个 Glassfish 警告(该死的老...: http://java.net/projects/glassfish/lists/ persistence/archive/2006-11/message/221)并且并不危险(这是因为 drop.ddl 仅删除序列表中的一行而不是整个表)。

时都会看到此错误弹出窗口。有什么想法可以在不失去创建和删除功能的情况下摆脱它吗?

每次保存资源 persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0">
    <persistence-unit name="JPATestsCascadePU" transaction-type="JTA">
        <jta-data-source>jdbc/myDB</jta-data-source>
        <properties>
            <property name="eclipselink.ddl-generation" 
                              value="drop-and-create-tables" />
        </properties>
    </persistence-unit>
</persistence>

使用自动生成 ID 的示例实体:

@Entity
public class Website {

    @Id
    @GeneratedValue
    private long id;

    private String value;

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }    
}

I have some problems with Eclipse server adapter for Glassfish 3.1. I am using the JPA auto generated identifiers. If the server is running and I have a create-and-drop policy for JPA, than each time the hot redeploy occurs I've got a big fat Eclipse error message thrown in my face:

cannot Deploy MyWebApp Deployment Error for module: MyWebApp:

PER01003: Deployment encountered SQL Exceptions:
PER01000: Got SQLException executing statement "CREATE TABLE SEQUENCE (SEQ_NAME
VARCHAR(50) NOT NULL, SEQ_COUNT DECIMAL(38), PRIMARY KEY (SEQ_NAME))":

org.postgresql.util.PSQLException: ERROR: relation "sequence" already exists

I am aware that this is just a Glassfish warning (damn old...: http://java.net/projects/glassfish/lists/persistence/archive/2006-11/message/221) and is not dangerous (it's because the drop.ddl is deleting just one sequence-table row instead of the whole table).

It's just a PITA to see this error popup each time I save a resource. Any ideas how to get rid of it without loosing create-and-drop functionality? At least to make it not disturbing while developing...

My persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0">
    <persistence-unit name="JPATestsCascadePU" transaction-type="JTA">
        <jta-data-source>jdbc/myDB</jta-data-source>
        <properties>
            <property name="eclipselink.ddl-generation" 
                              value="drop-and-create-tables" />
        </properties>
    </persistence-unit>
</persistence>

Exemplary entity using auto generated ID:

@Entity
public class Website {

    @Id
    @GeneratedValue
    private long id;

    private String value;

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }    
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淡淡的优雅 2024-12-18 05:29:12

您不会喜欢这个答案:在服务器上执行初始运行后关闭创建和删除功能。

老实说,创建​​和删除似乎会减慢重新部署的速度……这就是保存资源时发生的情况。

您可以通过关闭自动发布来减少该消息的出现频率...

注意:此问题适用于 2011 年 10 月 24 日之前发布的 Eclipse 的 GlassFish 集成插件,当它们与 GlassFish Server 3.1.1 及更早版本交互时。

You won't like this answer: turn off the create-and-drop functionality after you do your initial Run on Server.

To be honest, create-and-drop seems like it will slow down redeployment... which is what is happening when you save a resource.

You can make the message appear less often by turning off automatic publishing...

Note: this issue applies to GlassFish integration plugins for Eclipse released before 2011-10-24 when they interact with GlassFish Server 3.1.1 and younger.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文