2010-09-01 16 views
-2

我的應用程序拋出此異常。 我使用的Java DB作爲後端,我使用JPAjava.sql.SQLException:Schema'ADMIN'中已存在表/視圖'SEQUENCE'

內部異常: 值java.sql.SQLException:表/視圖 「零花錢」已經存在於架構 「應用」。錯誤代碼:30000電話:CREATE TABLE APP.POCKETMONEY(ID INTEGER NOT NULL,DateofSpending日期,說明 VARCHAR(255),AMOUNT INTEGER,PRIMARY KEY (ID))查詢:DataModifyQuery()

內部異常: java.sql.SQLException:表/視圖 'SEQUENCE'已經存在於Schema 'ADMIN'中。錯誤代碼:30000電話: CREATE TABLE SEQUENCE(SEQ_NAME VARCHAR(50)NOT NULL,SEQ_COUNT 十進制,PRIMARY KEY(SEQ_NAME)) 查詢:DataModifyQuery()

這裏是我的JPA代碼

/* 
* To change this template, choose Tools | Templates 
* and open the template in the editor. 
*/ 
package mymoney; 

import java.io.Serializable; 
import java.util.Date; 
import javax.persistence.Column; 
import javax.persistence.Entity; 
import javax.persistence.GeneratedValue; 
import javax.persistence.GenerationType; 
import javax.persistence.Id; 
import javax.persistence.Table; 
import javax.persistence.Temporal; 
import javax.persistence.TemporalType; 

/** 
* 
* @author sugan 
*/ 
@Entity 
@Table(schema = "APP") 
public class pocketMoney implements Serializable { 

    private static final long serialVersionUID = 1L; 
    @Id 
    @GeneratedValue(strategy=GenerationType.TABLE) 
    private int id; 
    @Temporal(TemporalType.DATE) 
    @Column(name = "DateofSpending") 
    private Date dos; 
    private String description; 
    private int amount; 

    public int getAmount() { 
     return amount; 
    } 

    public void setAmount(int amount) { 
     this.amount = amount; 
    } 

    public String getDescription() { 
     return description; 
    } 

    public void setDescription(String description) { 
     this.description = description; 
    } 

    public Date getDos() { 
     return dos; 
    } 

    public void setDos(Date dos) { 
     this.dos = dos; 
    } 

    public int getId() { 
     return id; 
    } 

    public void setId(int id) { 
     this.id = id; 
    } 

    @Override 
    public int hashCode() { 
     int hash = 0; 
     hash += (int) id; 
     return hash; 
    } 

    @Override 
    public boolean equals(Object object) { 
     // TODO: Warning - this method won't work in the case the id fields are not set 
     if (!(object instanceof pocketMoney)) { 
      return false; 
     } 
     pocketMoney other = (pocketMoney) object; 
     if (this.id != other.id) { 
      return false; 
     } 
     return true; 
    } 

    @Override 
    public String toString() { 
     return "mymoney.pocketMoney[id=" + id + "]"; 
    } 
} 

的persistence.xml

<?xml version="1.0" encoding="UTF-8"?> 
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"> 
    <persistence-unit name="myMoneyPU" transaction-type="RESOURCE_LOCAL"> 
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> 
    <class>mymoney.pocketMoney</class> 
    <properties> 
     <property name="eclipselink.jdbc.password" value="adminadmin"/> 
     <property name="eclipselink.jdbc.user" value="admin"/> 
     <property name="eclipselink.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/> 
     <property name="eclipselink.jdbc.url" value="jdbc:derby:pocketmoney;create=true"/> 
     <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/> 
    </properties> 
    </persistence-unit> 
</persistence> 
+2

在沒有看到代碼,這會導致錯誤(如果你在消息IIRC仔細一看,他們會被記錄爲警告),我只能翻譯錯誤信息。看起來你的代碼正在試圖創建已經存在於你的數據庫中的表...... – 2010-09-01 08:38:18

回答

2

無論JPA你使用供應商,我懷疑它被配置到g嵌套並導出與映射對應的數據庫對象......以及那些已存在的數據庫對象。

根據您的配置,在JPA提供程序上,確切消息(EclipseLink會記錄警告AFAIK等消息),這可能只是正常或「配置錯誤」。

如果您想了解更多詳情,請告訴我們您正在使用的服務提供商,並出示您的persistence.xml

更新:由於懷疑,你正在使用的EclipseLink而這些消息是「正常」的