Which statement is correct about the Java Persistence API support for the SQL queries?
A.
SQL queries are NOT allowed to use parameters.
B.
The result of an SQL query is not limited to entities.
C.
Only SELECT SQL queries are required to be supported.
D.
SQL queries are expected to be portable across databases.
Query results are not limited to entity objects. JPA 2 adds the ability to use almost any valid JPQL expression in SELECT clauses. Specifying the required query results more precisely can improve performance and in some cases can also reduce the amount of Java code needed. Notice that query results must always be specified explicitly – JPQL does not support the “SELECT *” expression (which is commonly used in SQL).
http://www.objectdb.com/java/jpa/query/jpql/select
JPQL queries can also return results which are not entity objects.
For example, the following query returns country names as String instances,
rather than Country objects:
SELECT c.name FROM Country AS c
Using path expressions,
such as c.name, in query results is referred to as projection.
I would say that D is the correct answer.
Explanation from the JPA 2 Pro book:
The Java Persistence Query Language (JP QL) is the standard query language of JPA. It is a portable query language designed to combine the syntax and simple query semantics of SQL with the expressiveness of an object-oriented expression language.
Queries written using this language can be portably compiled to SQL on all major database servers.
JPQL is portable, but SQL itself may not be portable. So, D is not correct.
I think B is the answer because the query result can include entities or scalar expression, such as count , sum, max, min, avg.