Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.

7.4. The select clause


The select clause picks which objects and properties to return in the query result set. Consider:
select mate 
from Cat as cat 
    inner join cat.mate as mate
The query will select mates of other Cats. Actually, you may express this query more compactly as:
select cat.mate from Cat cat
Queries may return properties of any value type including properties of component type:
select cat.name from DomesticCat cat
where cat.name like 'fri%'
select cust.name.firstName from Customer as cust
Queries may return multiple objects and/or properties as an array of type Object[],
select mother, offspr, mate.name 
from DomesticCat as mother
    inner join mother.mate as mate
    left outer join mother.kittens as offspr
or as a List (HQL specific feature)
select new list(mother, offspr, mate.name)
from DomesticCat as mother
    inner join mother.mate as mate
    left outer join mother.kittens as offspr
or as an actual typesafe Java object,
select new Family(mother, mate, offspr)
from DomesticCat as mother
    join mother.mate as mate
    left join mother.kittens as offspr
assuming that the class Family has an appropriate constructor.
You may assign aliases to selected expressions using as:
select max(bodyWeight) as max, min(bodyWeight) as min, count(*) as n
from Cat cat
This is most useful when used together with select new map (HQL specific feature):
select new map( max(bodyWeight) as max, min(bodyWeight) as min, count(*) as n )
from Cat cat
This query returns a Map from aliases to selected values.
Red Hat logoGithubredditYoutubeTwitter

Lernen

Testen, kaufen und verkaufen

Communitys

Über Red Hat Dokumentation

Wir helfen Red Hat Benutzern, mit unseren Produkten und Diensten innovativ zu sein und ihre Ziele zu erreichen – mit Inhalten, denen sie vertrauen können. Entdecken Sie unsere neuesten Updates.

Mehr Inklusion in Open Source

Red Hat hat sich verpflichtet, problematische Sprache in unserem Code, unserer Dokumentation und unseren Web-Eigenschaften zu ersetzen. Weitere Einzelheiten finden Sie in Red Hat Blog.

Über Red Hat

Wir liefern gehärtete Lösungen, die es Unternehmen leichter machen, plattform- und umgebungsübergreifend zu arbeiten, vom zentralen Rechenzentrum bis zum Netzwerkrand.

Theme

© 2026 Red Hat
Nach oben