About GROUP BY
GROUP BY and HAVING clauses
Explains how to use the GROUP BY and HAVING clauses in a JPA/JPQL query. The GROUP BY clause enables grouping of query results. A JPQL query with a GROUP BY clause returns properties of generated groups instead of individual objects and fields. The position of a GROUP BY clause in the query execution order is afte ...
JPA Query Structure (JPQL / Criteria)
Explains the structure of a JPQL query, which consists of 6 clauses: SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY. The syntax of the Java Persistence Query Language (JPQL) is very similar to the syntax of SQL. Having a SQL like syntax in JPA queries is an important advantage because SQL is a very powerful query language and many developers are already familiar wi ...
ORDER BY clause (JPQL / Criteria API)
Explains how to use the ORDER BY clause in a JPA/JPQL query. The ORDER BY clause specifies a required order for the query results. Any JPQL query that does not include an ORDER BY clause produces results in an undefined and non-deterministic order. This page covers the following topics: ...
Chapter 4 - JPA Queries (JPQL / Criteria)
Describes the Java Persistence Query Language (JPQL), the JPA Criteria API, and explains how to use queries in JPA. The JPA Query Language (JPQL) can be considered as an object oriented version of SQL. Users familiar with SQL should find JPQL very easy to learn and use. This chapter explains how to use JPQL as well as how to use the JPA Criteria API, which provide ...
Step 1: Create a Maven Web Project
Explains how to create a NetBeans Web Maven project with Spring and ObjectDB/JPA support. We start by creating a new Maven web project in NetBeans: Open the [New Project] dialog box, e.g. by using File > New Project... Select Maven > Maven Web Application and click Next . Choose a Project Name (e.g. Guestboo ...
Step 1: Create a Maven Web Project
Explains how to create a Eclipse Web Maven project with Spring and ObjectDB/JPA support. We start by creating a new Maven-WTP dynamic web project in Eclipse: Open the [New Project] dialog box, e.g. by using File > New > Project... Select Maven > Maven Project and click Next . Verify that the Create a simpl ...
Help with JPA2 Criteria and conditional operator grouping
Hi, I'm getting a little trouble performing a query as per the way I had it set up on eclipselink. Essentially, the query I'm trying to generate is: SELECT $1 FROM Company $1 WHERE (($1.companyId=:p1) AND ($1.conditionOne=true)) AND (($1.conditionTwo=false) OR ($1.conditionThree=false)) From the JPA2 criteria: #1 2011-07-13 13:51 Hi, I'm getting a little trouble performing a query as per the way I had it set up on eclipsel ...
javax.persistence.criteria.CriteriaQuery
The CriteriaQuery interface defines functionality that is specific to top-level queries.(Interface of JPA)
Grouping by date()
Hi, For some time now we can use date and time function in queries to extract part of date time (from documentation): YEAR({d '2011-12-31'}) is evaluated to 2011. MONTH({d '2011-12-31'}) is evaluated to 12. DAY({d '2011-12-31'}) is evaluated to 31. HOUR({t '23:59:00'}) is evaluated to 23. MINUTE({t '23:59:00'}) is evaluated to 59. SECOND({t '23:59:00'}) is evaluated to 0. #1 2011-12-20 15:05 Hi, For some time now we can use date and time function in queries to extract part of date time (from doc ...
Group by date / time
Hi, I'm trying to create reporting query that will return entities grouped by year / mont / day. Each entity has it's own field that holds java.lang.Date. There is no function like YEAR(), MONTH() or DAY() in ODB. So, how to build queries similar to something like this: SELECT COUNT(id) FROM stats WHERE YEAR(record_date) = 2009 GROUP BY YEAR(record_date), MONTH(record_date) or maybe something like this: #1 2011-07-10 14:01 Hi, I'm trying to create reporting query that will return entities grouped by year / mont / day. Each ...