|
From: Mark P. <mar...@co...> - 2003-08-06 00:33:23
|
Hi,
I was playing around with spring and hibernate and ended up writing a
HibernateSaveCallback class that would seem to be generally useful. It
goes something like this, though there are many variations, maybe to the
point of parameterizing which method gets called on the session, passing
object arrays in the ctor...etc.
public class HibernateSaveCallback implements HibernateCallback {
private Object _object;
public HibernateSaveCallback(Object objectToSave) {
_object = objectToSave;
}
public Object doInHibernate(Session session)
throws HibernateException, RuntimeException {
session.save(_object);
return _object;
}
}
How do people generally handle saving to hibernate using the
HibernateTemplate in this case?
Cheers,
Mark
|