我现在正在使用JPA eclipselink并喜欢使用Eclipselink连接到我的数据库
我在“我的数据库”中有一些de表的类,而我有一个查询来获取我的条目:
final Query query = entityManager.createQuery("SELECT q FROM FDC_DBCHANGE q ORDER BY q.CHANGE_ID");
我为我的桌子做了一些课程:
FDC_DBCHANGE
package com.bechtle.dbchanges.model;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
@Entity
public class FDC_DBCHANGE {
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private long CHANGE_ID;
private String CHANGE_NAME;
private String CHANGE_DATE;
private int CHANGE_NUMBER;
@OneToMany(mappedBy = "FDC_DBCHANGE")
private final List<FDC_EXECUTED> checkBoxes = new ArrayList<FDC_EXECUTED>();
public String getChangeName() {
return CHANGE_NAME;
}
public void setChangeName(final String pChangeName) {
CHANGE_NAME = pChangeName;
}
public String getChangeDate() {
return CHANGE_DATE;
}
public void setChangeDate(final String pChangeDate) {
CHANGE_DATE = pChangeDate;
}
public int getChangeNumber() {
return CHANGE_NUMBER;
}
public void setChangeNumber(final int pChangeNumber) {
CHANGE_NUMBER = pChangeNumber;
}
public List<FDC_EXECUTED> getCheckBoxes() {
return checkBoxes;
}
@Override
public String toString() {
return "FDC_DBCHANGE [CHANGE_NAME=" + CHANGE_NAME + ", CHANGE_DATE="
+ CHANGE_DATE + "CHANGE_NUMBER=" + CHANGE_NUMBER + "]";
}
}
FDC_EXECUTED
package com.bechtle.dbchanges.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
@Entity
public class FDC_EXECUTED {
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private int ENTRY_ID;
private FDC_DBCHANGE FDC_DBCHANGE;
private FDC_SYSTEM FDC_SYSTEM;
@OneToOne
@JoinColumn
public FDC_DBCHANGE getDbChange() {
return FDC_DBCHANGE;
}
public void setDbChange(final FDC_DBCHANGE pDbChange) {
FDC_DBCHANGE = pDbChange;
}
@OneToOne
@JoinColumn
public FDC_SYSTEM getSystem() {
return FDC_SYSTEM;
}
public void setSystem(final FDC_SYSTEM pSystem) {
FDC_SYSTEM = pSystem;
}
}
和 FDC_SYSTEM
package com.bechtle.dbchanges.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
@Entity
public class FDC_SYSTEM {
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private int SYSTEM_ID;
private String NAME;
private FDC_EXECUTED fdcexecuted;
public String getName() {
return NAME;
}
public void setName(final String pName) {
NAME = pName;
}
@OneToMany(mappedBy = "FED_SYSTEM")
public FDC_EXECUTED getExecuted() {
return fdcexecuted;
}
public void setExecuted(final FDC_EXECUTED pExecuted) {
fdcexecuted = pExecuted;
}
}
当我在Tomcat上运行它时会出现以下异常:
org.springframework.web.util.NestedServletException:请求处理失败;嵌套异常是Exception [EclipseLink-4002](Eclipse Persistence Services - 2.5.0.v20130507-3faac2b):org.eclipse.persistence.exceptions.DatabaseException 内部异常:java.sql.SQLSyntaxErrorException:ORA-00904:&#34; FDC_DBCHANGE_CHANGE_ID&#34;:无效标识符
错误代码:904 调用:SELECT ENTRY_ID,FDC_DBCHANGE_CHANGE_ID,FDC_SYSTEM_SYSTEM_ID FROM FDC_EXECUTED WHERE(FDC_DBCHANGE_CHANGE_ID =?) bind =&gt; [1参数界限] 查询:ReadAllQuery(name =&#34; checkBoxes&#34; referenceClass = FDC_EXECUTED sql =&#34; SELECT ENTRY_ID,FDC_DBCHANGE_CHANGE_ID,FDC_SYSTEM_SYSTEM_ID FROM FDC_EXECUTED WHERE(FDC_DBCHANGE_CHANGE_ID =?)&#34;) org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:932) org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:816) javax.servlet.http.HttpServlet.service(HttpServlet.java:620) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:801) javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
Eclipselink尝试运行SQL语句SELECT ENTRY_ID, FDC_DBCHANGE_CHANGE_ID , FDC_SYSTEM_SYSTEM_ID FROM FDC_EXECUTED WHERE( FDC_DBCHANGE_CHANGE_ID =?)
代替SELECT ENTRY_ID, CHANGE_ID , SYSTEM_ID FROM FDC_EXECUTED WHERE( CHANGE_ID =?)
我不知道为什么......
我希望有人可以帮助我,抱歉我的英语不好......
obsidianfarmer
答案 0 :(得分:0)
好的,问题解决了,原因是Eclipselink需要一个我无法访问的OID,这就是问题......