在我的应用程序中,我有以下 2 个实体:
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public class Commentable implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
protected Long id;
protected long createdDate;
...
}
@Entity
public class Announcement extends Commentable implements Serializable {
private int type;
private String title;
@Column(columnDefinition = "MEDIUMTEXT")
private String content;
...
}
当我尝试从 Announcement 表中获取一些行时,我不断收到以下行的语法错误:
Query q = em.createQuery("SELECT A FROM Announcement A JOIN Commentable C ON A.id = C.id WHERE A.type=:type ORDER BY C.createdDate DESC");
这是堆栈跟踪:
Caused by: Exception [EclipseLink-8023] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.JPQLException
Exception Description: Syntax error parsing the query [SELECT A FROM Announcement A JOIN Commentable C ON A.id = C.id WHERE A.type=:type ORDER BY C.createdDate DESC].
Internal Exception: org.eclipse.persistence.internal.libraries.antlr.runtime.EarlyExitException
如果您能告诉我我在这里做错了什么,我将不胜感激。
最好的问候,詹姆斯·特兰