Hi,
it would be nice if we could keep the JDOTemplate JDO-version-agnostic,
Juergen did this perfectly with the detach/attach methods some time ago
(1.2.2 or something), so to me it seems straightforward to do the same
with getObjectById(Class clazz, Object id). I am thinking of something
like that:
---
[JDOTemplate.java]
...
public Object getObjectById(final Class entityClass, final Object
idValue) throws DataAccessException {
return execute(new JdoCallback() {
public Object doInJdo(PersistenceManager pm) throws JDOException {
return getJdoDialect().getObjectById(entityClass, idValue);
}
}, true);
}
...
In DefaultJDODialect we could place the JDO detection static initializer
and we would use it in the same way as before in getObjectById() in
JDOTemplate. Perhaps it would make sense to also create a protected
getJDOVersion() in JDODefaultDialect so that custom implementations of
JDODefaultDialect like MarcJDODialect could ask for the JDO version to
do special stuff if needed, would be easier than to directly access the
static attribute to the flag.
All in all we would have a cleaner JDOTemplate without unresolved
references for JDO1 developers looking at JDOTemplate. All these
unresolved things are hidden in JDODefaultDialect or not if you use
custom childs of it.
Tell me what you think.
BTW nice catch regarding JDO version detection ;-) I had to double check
that there is a difference at all.
I will start looking into the auto-detaching of JDOTemplate when
TransactionSynchronizationManager.hasResource(getPersistenceManagerFactory())
equals false.
Marc Logemann
http://www.logemann.org
|