This section lists known issues and associated solutions related to the Java Persistence API.
See https://glassfish.dev.java.net/issues/show_bug.cgi?id=572 for more information.
Do not use this type of query.
The query compiler does not check all the rules as defined in the Java Persistence Language chapter of the specification. In particular, it does not check:
Type compatibility of function arguments.
Type compatibility of operands of arithmetic, logical, and comparison operators
SELECT clause requirements for an ORDER BY query.
An invalid query may compile but may cause a SQLException at runtime. Or it might happen that the underlying database is less restrictive and supports the generated SQL, but executing the same query on a different database fails with a SQLException.
Verify the above conditions manually.
A query grouping by a JOIN variable and directly selecting the JOIN variable might result in a SQLException complaining about non-grouping expressions being selected. For more information, see https://glassfish.dev.java.net/issues/show_bug.cgi?id=197. For example:
SELECT AVG(o.totalPrice), c FROM Order o JOIN o.customer c GROUP BY c |
A possible workaround is to directly navigate the relationship instead of defining a JOIN variable; for example:
SELECT AVG(o.totalPrice), o.customer FROM Order GROUP BY o.customer |
For more information, see https://glassfish.dev.java.net/issues/show_bug.cgi?id=550.
Manually verify what is wrong in the query.
Use different class names.
For more information, see https://glassfish.dev.java.net/issues/show_bug.cgi?id=558.
Do not list MappedSuperclass explicitly.
For more information, see https://glassfish.dev.java.net/issues/show_bug.cgi?id=578.
Do not use ManyToMany relationship in a subclass.
For more information, see https://glassfish.dev.java.net/issues/show_bug.cgi?id=557.
Use java.util.Collection instead.
Use Java wrapper types for mapping to nullable database columns.
For more information, see https://glassfish.dev.java.net/issues/show_bug.cgi?id=404.
Access LAZY initialized relationship in server-side code before returning an instance to the client.
A query selecting a relationship field does not include null in the query result when the value of the relationship field is null. This entry is instead skipped from the query result; for example:
SELECT o.customer FROM Order o WHERE ... |
See https://glassfish.dev.java.net/issues/show_bug.cgi?id=637 for more information.
Select a state field from the related instance.
SELECT o.customer.customerId FROM Order o WHERE ... |
For example:
SELECT c FROM Order o LEFT OUTER JOIN o.customer c |
See https://glassfish.dev.java.net/issues/show_bug.cgi?id=638 for more information.
Select a state field from the related instance.
SELECT c.customerId FROM Order o LEFT OUTER JOIN o.customer c |
EntityManager.find() erroneously throws an IllegalArgumentException for an entity that is a subclass of another entity if the primary key class is defined by an @IdClass annotation. See https://glassfish.dev.java.net/issues/show_bug.cgi?id=595 for more information.
Use the class of the topmost superclass as the argument to the find() method, and cast the result to the subclass.
See https://glassfish.dev.java.net/issues/show_bug.cgi?id=643 for more information.
Use java.util.ArrayList as the initial value.