我收到以下hibernate查询语法异常
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected
AST node: = near line 1, column 59 [SELECT u FROM
com.vat.domain.entity.Employee u where (u.id = :id) <> 1]
代码:
public interface EmployeeRepository extends JpaRepository<Employee, Long>,
JpaSpecificationExecutor<Employee> {
public final static String FIND_BY_Datatable_Filter = "SELECT u FROM
Employee u where (u.id = :id) <> 1";
public final static String FIND_ALL_Active = "SELECT u FROM Employee u where
u.status = 'Enabled' <> 1";
@Query(FIND_BY_Datatable_Filter)
public Page<Employee> findByDatatableFilter(@Param("id") int id, Pageable
pageable);
@Query(FIND_ALL_Active)
public Page<Employee> findAllActiveEmployees(Pageable pageable);
}
请告诉我如何解决这个问题。
答案 0 :(得分:0)
您的查询错误。 SELECT *, (
SELECT *
FROM [address_bsm] A INNER JOIN [customer_bsm] B
ON a.id_cust = b.id_cust
FOR XML PATH ('Address_bsm'))
FROM [customer_bsm]
FOR XML PATH
不是有效的sytax。
我认为您的查询必须如下:
(u.id = :id) <> 1
但对我来说,这个表达式中的public final static String FIND_BY_Datatable_Filter = "SELECT u FROM
Employee u where (u.id = :id)";
public final static String FIND_ALL_Active = "SELECT u FROM Employee u where
u.status = 'Enabled'";
意味着什么并不是很清楚。