이 콘텐츠는 선택한 언어로 제공되지 않습니다.

3.3. Mapping Queries


3.3.Mapping JPAQL/HQL queries. Mapping JPAQL/HQL queries

You can map EJBQL/HQL queries using annotations. @NamedQuery and @NamedQueries can be defined at the class level or in a JPA XML file. However their definitions are global to the session factory/entity manager factory scope. A named query is defined by its name and the actual query string.
<entity-mappings>
    <named-query name="plane.getAll">
        <query>select p from Plane p</query>
    </named-query>
    ...
</entity-mappings>
...

@Entity
@NamedQuery(name="night.moreRecentThan", query="select n from Night n where n.date >= :date")
public class Night {
    ...
}

public class MyDao {
    doStuff() {
        Query q = s.getNamedQuery("night.moreRecentThan");
        q.setDate( "date", aMonthAgo );
        List results = q.list();
        ...
    }
    ...
}
Copy to Clipboard Toggle word wrap
You can also provide some hints to a query through an array of QueryHint through a hints attribute.
The availabe Hibernate hints are
Expand
Table 3.2. Query hints
hintdescription
org.hibernate.cacheableWhether the query should interact with the second level cache (default to false)
org.hibernate.cacheRegionCache region name (default used otherwise)
org.hibernate.timeoutQuery timeout
org.hibernate.fetchSizeresultset fetch size
org.hibernate.flushModeFlush mode used for this query
org.hibernate.cacheModeCache mode used for this query
org.hibernate.readOnlyEntities loaded by this query should be in read only mode or not (default to false)
org.hibernate.commentQuery comment added to the generated SQL
맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2025 Red Hat