简体   繁体   English

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

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

I created this project in Netbeans and it's the only way I know to access any of it. 我在Netbeans中创建了这个项目,这是我知道访问其中任何项目的唯一方法。 I can't seem to find the database where my objects are stored so that I may delete them. 我似乎找不到存储对象的数据库,因此可以删除它们。 In fact, I it's best if it simply deletes everything every time I restart glassfish. 实际上,最好是每次我重新启动glassfish时都删除所有内容。 I understand that changing a class would result in this kind of problem, but I don't know how to remove information about the old version of the class. 我知道更改类会导致这种问题,但是我不知道如何删除有关旧版本的信息。 Until now I've tried to work around the problem by refactoring the class name each time it changes but I've run out of creative names. 到目前为止,我一直在尝试通过每次更改类名称来重构类名称来解决该问题,但我的创意名称用完了。

The exception: 例外:

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 = ?)")

What I have made of this is that the new CURRENTDAY member of class FASTINTERNALCLOCK is not in the table it's looking for it for, probably because it's looking in a table based on the old version of the class where the member was not yet present. 我这样做的原因是,FASTINTERNALCLOCK类的新CURRENTDAY成员不在其要查找的表中,这可能是因为它是在基于该成员尚未存在的类的旧版本的表中查找的。 How can I delete this table so that it may be recreated with the new member in mind? 如何删除此表,以便可以在记住新成员的情况下重新创建它?

persistence.xml: 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程序,您可以使用该程序来访问数据库,并在需要时从数据库中删除表和/或行。

Try using the values"drop-and-create-tables" for DDL to drop and the create tables on deployment. 尝试使用值“ drop-and-create-tables”来删除DDL并在部署时创建表。 Glashfish sets up a default __datasource on an embedded derby database as described here http://docs.oracle.com/cd/E18930_01/html/821-2424/gksmw.html 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