您可能对 "entityManager.createNativeQuery("SQL Syntax query") 感兴趣,其中可以执行 SQL 语法查询。返回数据类型为 "ResultSet"。
ResultSet result = entityManager.createNativeQuery("Your_SQL_function").getSingleResult();
另一方面,'entityManager.createNamedQuery("defined-query-name")' 应该在代码执行之前定义其查询(在持久性配置或类注释中)。示例:在您的班级中名列前茅
@NamedQuery(id="findFirstEmployee" query="from Employees e where id = 1")
您的代码应如下所示:
public Employees getEmployeeRecords(String employeeNumber) {
Emloyee result = entityManager.createNamedQuery("findFirstEmployee").getSingleResult();
return result;
References:
http://www.oracle-base.com/articles/misc/using-ref-cursors-to-return-recordsets.php