【发布时间】:2016-09-11 09:29:44
【问题描述】:
这个NamedQuery有什么问题?
@NamedQuery(name = "Queries.findQueryIdsByRoleOfSameSid",
query = "SELECT q "+
"FROM Queries q "+
"WHERE ((q.issueRole = :issueRole) AND "+
"(SELECT COUNT(*) FROM Queries qb WHERE ( (q.sessionId=qb.sessionId) AND (q.issueRole=qb.issueRole))) IS NOT EMPTY)"+
"ORDER BY q.reqTime "),
这是查询实体属性:
public class Queries implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "query_id")
private Integer queryId;
@Basic(optional = false)
@NotNull
@Column(name = "issue_time")
private int issueTime;
@Basic(optional = false)
@NotNull
@Column(name = "issue_role")
private int issueRole;
@Basic(optional = false)
@NotNull
@Column(name = "req_time")
@Temporal(TemporalType.TIMESTAMP)
private Date reqTime;
@Basic(optional = false)
@NotNull
@Column(name = "sucess_flag")
private int sucessFlag;
@Size(max = 50)
@Column(name = "session_id")
private String sessionId;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "queriesQueryId")
private Collection<Statement> statementCollection;
我收到此错误,模块未部署:
Exception Description: Syntax error parsing the query [Queries.findQueryIdsByRoleOfSameSid: SELECT q FROM Queries q WHERE ((q.issueRole = :issueRole) AND (SELECT COUNT(*) FROM Queries qb WHERE ( (q.sessionId=qb.sessionId) AND (q.issueRole=qb.issueRole))) IS NOT EMPTY)ORDER BY q.reqTime ], line 1, column 44: syntax error at [=]. Internal Exception: MismatchedTokenException(82!=84). Please see server.log for more details.`
仅供参考,我正在使用 netbeans 7.2.1,默认 org.eclipse.persistence.jpa.PersistenceProvider(JPA 2.0) in persistence.xml
我什至尝试将 eclipsLink 版本升级到 2.6,但失败了。我不知道为什么,我完全按照这些instrctions How do you use EclipseLink 2.3 as persistence provider in NB 7? 还有这个 Adding the latest EclipseLink version to a Netbeans project?
请帮帮我
【问题讨论】:
-
第 1 行第 44 列的查询是什么?有问题...
-
作为计算结果为数字的 COUNT(*) 表达式,而不是 IS NOT EMPTY ,我将其更改为 > 1 。但仍然没有成功:(还有其他建议吗?
-
@maria 异常信息还是一样?
-
@maria BTW 我发现在
ORDER BY之前没有空间......即使它可能不是问题的原因 - 为了清楚起见添加空间。
标签: java mysql hibernate jpa netbeans