|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
javax.persistence Annotation Type NamedQuery
Implements:
Annotation
@Target(value=TYPE)@Retention(value=RUNTIME)
此类用于指定使用 Java Persistence 查询语言编写的指定查询,它在元数据中表示为静态查询。查询名称的范围限制在持久性单元内。
以下是定义使用 Java Persistence 查询语言编写的指定查询的示例:
@NamedQuery( name="findAllCustomersWithName", query="SELECT c FROM Customer c WHERE c.name LIKE :custName" )
以下是使用指定查询的示例:
@PersistenceContext public EntityManager em; ... customers = em.createNamedQuery("findAllCustomersWithName") .setParameter("custName", "Smith") .getResultList();
since |
|
Is used to specify a named query in the Java Persistence query language, which is a static query expressed in metadata. Query names are scoped to the persistence unit.
The following is an example of the definition of a named query in the Java Persistence query language:
@NamedQuery( name="findAllCustomersWithName", query="SELECT c FROM Customer c WHERE c.name LIKE :custName" )
The following is an example of the use of a named query:
@PersistenceContext public EntityManager em; ... customers = em.createNamedQuery("findAllCustomersWithName") .setParameter("custName", "Smith") .getResultList();
- Since:
- Java Persistence 1.0
Required Element Summary | |
---|---|
String |
name
Refers to the query when using the EntityManager
methods that create query objects. |
String |
query
The query string in the Java Persistence query language |
Optional Element Summary | |
---|---|
QueryHint[] |
hints
Vendor-specific query hints |
Element Detail |
---|
abstract public String
name()
在使用创建查询对象的 EntityManager
方法时引用查询。
英文文档:
name
public abstract String name
- Refers to the query when using the
EntityManager
methods that create query objects.
abstract public String
query()
使用 Java Persistence 查询语言编写的查询字符串
英文文档:
query
public abstract String query
- The query string in the Java Persistence query language
abstract public QueryHint[]
hints()
特定于供应商的查询提示
英文文档:
hints
public abstract QueryHint[] hints
- Vendor-specific query hints
- Default:
- {}
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
Submit a bug or feature
Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!