繁体   English   中英

在向成员添加类后,JPA崩溃,并显示SQLSyntaxErrorException。 如何删除旧类的痕迹?

[英]After adding a member a class, JPA crashes with a SQLSyntaxErrorException. How do I delete traces of the old class?

我在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如以下http://docs.oracle.com/cd/E18930_01/html/821-2424/gksmw.html所述,在嵌入式derby数据库上设置了默认的__datasource。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM