Whilst a “final release” of version 3.2 of DataNucleus is still some way off, some important changes have been made to the enhancement process that people need to be aware of, and can benefit from.
JDO : Ability to enhance all classes as “detachable” without updating metadata
When you enhance classes for the JPA API they are all made detachable without a need to specify anything in the metadata (since JPA doesn’t have a concept of not being detachable). With JDO the default is not detachable (for backwards compatibility with JDO1 which didn’t have the detachment concept). In v3.2 of DataNucleus you can set the alwaysDetachable option (see the enhancer docs ) and all classes will be enhanced detachable without the need to touch the metadata; much easier than opening up every class or metadata file and adding detachable=”true” !
JPA : Throwing of exceptions due to the bytecode enhancement contract
The bytecode enhancement contract requires that classes throw exceptions under some specific situations where information is either not present or not valid. These always used JDO-based exceptions before to match the JDO bytecode enhancement contract exactly. These are now changed to better suit the JPA API, and remove a need to understand JDO when using JPA.
- if a non-detached field was accessed then a JDODetachedFieldAccessException was thrown; this is now changed to an (java.lang.)IllegalAccessException.
- in some cases where an internal error occurred a JDOFatalInternalException would be thrown; this is now changed to an (java.lang.)IllegalStateException.