当前位置:首页 > Struts2.1.8+Spring2.5.6+Hibernate3.6.8框架搭建+
控制数据源内加载的PreparedStatements数量。 如果maxStatements与 maxStatementsPerConnection均为0,则缓存被关闭。Default: 0 --> name=\value=\ value=\y> ---------------------- jdbc.properties配置文件的内容 ------------------------ jdbcUrl = jdbc:mysql:///itcastoa driverClass = com.mysql.jdbc.Driver username = root password = 1234 2、测试代码 SpringTest.java private ApplicationContext ac = new ClassPathXmlApplicationContext( \ontext.xml\ @Test// 测试 SessionFactory 的配置 public void testSessionFactory(){ SessionFactory sessionFactory = (SessionFactory) ac.getBean(\ Assert.assertNotNull(sessionFactory.openSession()); } 2、配置声明式事务(使用基于注解的方式) 1、配置 class=\ernateTransactionManager\ transaction-manager=\ 2、测试代码 1、Service类 @Service public class InsertUserService { @Resource private SessionFactory sessionFactory; @Transactional public void addUsers() { sessionFactory.getCurrentSession().save(new User()); // int a = 1 / 0; // 这行会抛异常 sessionFactory.getCurrentSession().save(new User()); } } 2、单元测试
共分享92篇相关文档