public List findByExample(Book instance) {
log.debug("finding Book instance by example");
try {
List results = getHibernateTemplate().findByExample(instance);
log.debug("find by example successful, result size: "
+ results.size());
return results;
} catch (RuntimeException re) {
log.error("find by example failed", re);
throw re;
}
}
--------------------------------------------
public Book merge(Book detachedInstance) {
log.debug("merging Book instance");
try {
Book result = (Book) getHibernateTemplate().merge(detachedInstance);
log.debug("merge successful");
return result;
} catch (RuntimeException re) {
log.error("merge failed", re);
throw re;
}
}
-----------------------------------------------
public void attachDirty(Book instance) {
log.debug("attaching dirty Book instance");
try {
getHibernateTemplate().saveOrUpdate(instance);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
}
----------------------------------------
public void attachClean(Book instance) {
log.debug("attaching clean Book instance");
try {
getHibernateTemplate().lock(instance, LockMode.NONE);
log.debug("attach successful");
} catch (RuntimeException re) {
log.error("attach failed", re);
throw re;
}
} public static BookDAO getFromApplicationContext(ApplicationContext ctx) {
return (BookDAO) ctx.getBean("BookDAO");
}
上面几个方法是什么意思,我现在整合ssh2,不需要使用session来进行事物处理么?
看见别人都是直接在struts里面调用dao是不是该加个中间层呢