在向类中添加成员之后,JPA会崩溃并产生sqlsyntaxerroreexception.如何删除旧类的踪迹



我在Netbeans中创建了这个项目,这是我知道访问它的唯一方法。我似乎找不到存储我的对象的数据库,所以我可以删除它们。事实上,如果每次我重新启动glassfish时它都删除所有内容,这是最好的。我知道更改类会导致这种问题,但我不知道如何删除旧版本类的信息。到目前为止,我一直试图通过每次更改类名来重构这个问题,但我已经用尽了创造性的名称。

例外:

javax.servlet.ServletException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: Column 'CURRENTDAY' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE  statement then 'CURRENTDAY' is not a column in the target table.
Error Code: -1
Call: SELECT ID, CURRENTDAY, INTERNAL_TIME_M, LASTTIME_M FROM FASTINTERNALCLOCK WHERE (ID = ?)
    bind => [1 parameter bound]
Query: ReadObjectQuery(name="readObject" referenceClass=FastInternalClock sql="SELECT ID, CURRENTDAY, INTERNAL_TIME_M, LASTTIME_M FROM FASTINTERNALCLOCK WHERE (ID = ?)")

我所做的是,类FASTINTERNALCLOCK的新CURRENTDAY成员不在它正在查找的表中,可能是因为它正在查找基于旧版本的类,其中成员尚未存在的表。我怎样才能删除这个表,以便用新成员重新创建它?

persistence . xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.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_2_0.xsd">
  <persistence-unit name="webThermosPU" transaction-type="JTA">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <jta-data-source>jdbc/__default</jta-data-source>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties>
      <property name="eclipselink.ddl-generation" value="create-tables"/>
    </properties>
  </persistence-unit>
</persistence>

您的SQL安装应该带有一个WorkBench程序,您可以使用该程序访问数据库,并在需要时从中删除表和/或行。

尝试使用值"drop-and-create-tables"让DDL在部署时删除和创建表。Glashfish在嵌入式derby数据库上设置默认的__datasource,如下所示http://docs.oracle.com/cd/E18930_01/html/821-2424/gksmw.html

相关内容

  • 没有找到相关文章

最新更新