Details
-
New Feature
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
Description
One of the major addition in JPA 2.0 is type-aware Criteria query construction. A string-based JPQL can become invalid when a persistent entity property changes its name or type, but such error is detected only at runtime. On the other hand, for a Criteria query, such an error will be detected at compile time.
This primary usability advantage of Criteria query can really become useful in an IDE with refactoring support. The native refactoring support provided by IDE though is not sufficient.
For example, when a persistent property 'xyz' of entity C is renamed to 'abc', the native refactoring support will appropriately change all references to 'C.xyz' to 'C.abc'. However, a Criteria query is built with reference to C_.xyz and not C.xyz where C_ is the meta-class corresponding to C. Hence, a IDE plugin should expand the footprint of refactoring to include C_.xyz when C.xyz changes.