Session session = getSession();
tx = session.beginTransaction();
session.save(vo);
session.flush();
tx.commit();
session.close();
-----------------------
你可以在配置中配置自动提交
tx = session.beginTransaction();
session.save(vo);
session.flush();
tx.commit();
session.close();
-----------------------
你可以在配置中配置自动提交
解决方案 »
- Java 有关 图片上传问题
- 大神,正则表达式的问题!求解
- STRUTS2中如何加载资源文件
- 选课系统的登录JSP代码有什么问题
- Unable to load tag handler class "org.springframework.web.servlet.tags.form.FormTag" for tag "forms:form"
- ibatis调用oracle存储过程参数问题
- jbuilder 2006 EJB出现异常javax.naming.NameNotFoundException: Unable to resolve 'bmp' Resolved ; remaining name 'bmp'
- tomcat5.0.28配置servlet老是出错
- 想请教一下各位web service高手,有没有必要看w3c的wsdl规范阿?
- 如何进入java世界??
- <html:text value=<%=("sfdsd");%> />这句错误在那?
- 高分求解 Spring+JDBC 启动时出错
public class ICatDAO() {
public Cat saveCat(Cat cat);
}
public class CatHibernateDAO() extends HibernateDaoTemplate implements ICatDAO {
public Cat saveCat(Cat cat) {
try {
this.getHibernateTemplate().save(cat)
return cat;
}
catch(DataAccessException dae) {
...
}
}
}public class ICatService() {
public Cat saveCat(Cat cat);
}public class CatServiceImp() implements ICatService {
private ICatDAO catDAO; //add set, get
public Cat saveCat(Cat cat) {
this.getCatDAO().saveCat(cat);
}
}还需要一个取得数据连接配置的类,从你的配置里面取得bean id
//Action in struts
public class MyAction
extends Action {
private ICatService catService
private WebApplicationContext wac;
public void setServlet(ActionServlet actionServlet) {
super.setServlet(actionServlet);
ServletContext servletContext = actionServlet.getServletContext();
this.wac = WebApplicationContextUtils.getRequiredWebApplicationContex(servletContext);
this.catService = (ICatService)wac.getBean("cat");//spring.xml
}
public ICatService getCatService() {
return catService;
}//