Sun Java System Application Server Platform Edition 9 Release Notes

Java Persistence API

This section lists known issues and associated solutions related to the Java Persistence API.

An UPDATE or DELETE query using a subquery in the WHERE clause results in a NullPointerException during query compilation.

See https://glassfish.dev.java.net/issues/show_bug.cgi?id=572 for more information.

Solution

Do not use this type of query.

The query compiler does not check all the rules as defined in the Java Persistence Language specification.

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:

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.

Solution

Verify the above conditions manually.

A query grouping by a JOIN variable and directly selecting the JOIN variable might result in a SQLException

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

Solution

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

In some cases, the query compiler throws a misleading error message, because it mentions the wrong token in the error message.

For more information, see https://glassfish.dev.java.net/issues/show_bug.cgi?id=550.

Solution

Manually verify what is wrong in the query.

Two persistence units containing the same class cannot currently be deployed in the same EAR file.

Solution

Use different class names.

You cannot list MappedSuperclass explicitly using class element in persistence.xml.

For more information, see https://glassfish.dev.java.net/issues/show_bug.cgi?id=558.

Solution

Do not list MappedSuperclass explicitly.

Entity mapping @ManyToMany fails on inherited class.

For more information, see https://glassfish.dev.java.net/issues/show_bug.cgi?id=578.

Solution

Do not use ManyToMany relationship in a subclass.

Using List<> for a relationship causes StringIndexOutOfBoundException in MetadataHelper.getAttributeNameFromMethodName.

For more information, see https://glassfish.dev.java.net/issues/show_bug.cgi?id=557.

Solution

Use java.util.Collection instead.

Unable to map null database values to primitives.

Solution

Use Java wrapper types for mapping to nullable database columns.

Accessing a LAZY initialized relationship from client side sometimes causes a NullPointerException.

For more information, see https://glassfish.dev.java.net/issues/show_bug.cgi?id=404.

Solution

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.

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.

Solution

Select a state field from the related instance.


SELECT o.customer.customerId FROM Order o WHERE ...

A query selecting a JOIN identification variable defined for a single valued relationship field may result in invalid SQL.

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.

Solution

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

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.

Solution

Use the class of the topmost superclass as the argument to the find() method, and cast the result to the subclass.

Cannot persist an entity with relationship field set to a java.util.HashSet.

See https://glassfish.dev.java.net/issues/show_bug.cgi?id=643 for more information.

Solution

Use java.util.ArrayList as the initial value.