Professional Documents
Culture Documents
Objectives
Ver. 1.0
Slide 1 of 28
Ver. 1.0
Slide 2 of 28
A query object:
Is an instance of the javax.persistence.Query interface.
Encapsulates either a QL query string or a native (SQL) query
string.
Ver. 1.0
Slide 3 of 28
Ver. 1.0
Slide 4 of 28
Named queries:
Are the static queries expressed in metadata.
Can be defined in QL or in SQL.
Ver. 1.0
@Entity
@NamedQuery(name="FindAllClosedAuctions",
query=" SELECT OBJECT(a) FROM Auction AS a +
WHERE a.status= CLOSED")
public class Auction implements Serializable {
// ...
}
Slide 5 of 28
Ver. 1.0
Slide 6 of 28
Ver. 1.0
Slide 7 of 28
Ver. 1.0
Slide 8 of 28
Ver. 1.0
Slide 9 of 28
Ver. 1.0
Slide 10 of 28
Ver. 1.0
Slide 11 of 28
Ver. 1.0
Slide 12 of 28
Ver. 1.0
Slide 13 of 28
Ver. 1.0
Slide 14 of 28
Ver. 1.0
Slide 15 of 28
Ver. 1.0
Slide 16 of 28
Ver. 1.0
Slide 17 of 28
Ver. 1.0
Slide 18 of 28
Ver. 1.0
Conditional Expression
Operators
Operand Type
Comparison expression
Arithmetic
Between expression
[NOT] BETWEEN
Arithmetic, string,
date_time
Like expression
[NOT] LIKE
String
In expression
IS [NOT] NULL
All types
IS [NOT] EMPTY
Collection
[NOT] MEMBER OF
Collection
Exist expression
[NOT] LIKE
String
Slide 19 of 28
Ver. 1.0
Slide 20 of 28
Ver. 1.0
Slide 21 of 28
Ver. 1.0
Return Type
CONCAT(String, String)
String
SUBSTRING(String, String)
String
TRIM(String, String)
String
LOWER(String)
String
UPPER(String)
String
int
LENGTH(String)
int
ABS(number)
LOWER(String)
double
SQRT(double)
double
MOD(int, int)
int
SIZE(Collection_valued_path_expr)
int
Slide 22 of 28
A constructor expression:
SELECT NEW com.acme.example.CustomerDetails(c.id,
c.status, o.count) FROM
Customer c JOIN c.orders o WHERE o.count > 100
Ver. 1.0
Slide 23 of 28
Ver. 1.0
Slide 24 of 28
Ver. 1.0
Slide 25 of 28
Ver. 1.0
Slide 26 of 28
Ver. 1.0
Slide 27 of 28
Ver. 1.0
Slide 28 of 28