Since the days of JPOX we've always used the JDO bytecode enhancement contract as defined in the JDO spec. This has always been adequate to provide the necessary hooks into the object to allow for "transparent persistence". Saying that though, it does mean that anyone using DataNucleus would always have to have jdo-api.jar in their CLASSPATH, even when using JPA. This was clearly undesirable, but not a large price to pay for easy provision of JPA.
In v4.0 onwards we will enhance classes to implement org.datanucleus.enhancer.Persistable. This is very similar in terms of structure, just that methods are now prefixed "dn" instead of "jdo", and there is now a method to get the ExecutionContext that is managing the object (whereas before it was a PersistenceManager, which made very little sense for JPA usage).
Why the change?
Oracle is putting significant obstacles in the way of having further releases of the JDO standard, involving lawyers etc. Additionally, following the Apache way, the Apache JDO project has not exactly operated very efficiently in terms of getting releases out of the door. Moreover we want to remove the requirement of having to have jdo-api.jar in the CLASSPATH for JPA usage. This change will also mean that we can, in principle, improve the bytecode enhancement contract to make things more efficient or add on more information to enhance the persistence process without being restricted by what JDO has bothered to standardise.
What does this mean for a typical user?
It means very little in reality, and the majority of applications will work unchanged (apart from having to re-enhance the classes). Some minor things that will change
- Wherever you use enhanced classes, you will need datanucleus-core.jar in the CLASSPATH
- JPA users won't need to have jdo-api.jar in the CLASSPATH
- Internally DataNucleus now uses its own builtin single-field identity classes, and if you refer to javax.jdo.identity.* classes (for JDO contexts) will auto-convert to our own class for internal use. See this package for the DN internal identity classes. There is really no need to use these JDO builtin classes directly since DataNucleus will always select the most appropriate id type when you have a single PK field.
- You no longer check if a returned object is of type javax.jdo.spi.PersistenceCapable since it won't be, instead being a org.datanucleus.enhancer.Persistable.
Please register any concerns/queries in the comments section