JAVA 代码:
1.
@Entity
2.
@NamedQuery(name="findByName", queryString =
3.
"SELECT o FROM People o WHERE o.name = :queryname")
4.
public class People{
5.
...
6.
}
则对接口public List<People> findByNamedQueryAndNamedParam(String queryName, String[] paramNames, Object[] values);
调用
复制内容到剪贴板
JAVA 代码:
1.
List<People> peoples=XXXXXXX.findByNamedQueryAndNamedParam("findByName",
2.
new String[]{"queryname"},new String[]{"ABCD"});
相当于将name为findByName的queryString中的queryname参数换成ABCD.
效果就相当于执行SELECT o FROM People o WHERE o.name = 'ABCD'
1.
@Entity
2.
@NamedQuery(name="findByName", queryString =
3.
"SELECT o FROM People o WHERE o.name = :queryname")
4.
public class People{
5.
...
6.
}
则对接口public List<People> findByNamedQueryAndNamedParam(String queryName, String[] paramNames, Object[] values);
调用
复制内容到剪贴板
JAVA 代码:
1.
List<People> peoples=XXXXXXX.findByNamedQueryAndNamedParam("findByName",
2.
new String[]{"queryname"},new String[]{"ABCD"});
相当于将name为findByName的queryString中的queryname参数换成ABCD.
效果就相当于执行SELECT o FROM People o WHERE o.name = 'ABCD'