日期:2014-05-20  浏览次数:20760 次

SSH中 getHibernateTemplate().saveOrUpdate不执行
我是ssh初学者,今天用getHibernateTemplate().find()可以得到结果,但是getHibernateTemplate().saveOrUpdate(table)
无法执行insert

我的配置如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
  xmlns:tx="http://www.springframework.org/schema/tx"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
  <!--<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">-->
  <!--数据库驱动,我这里使用的是Mysql数据库 -->
  <!--<property name="driverClassName">-->
  <!--<value>com.mysql.jdbc.Driver</value>-->
  <!--</property>-->
  <!--数据库地址,这里也要注意一下编码,不然乱码可是很郁闷的哦! -->
  <!--<property name="url">-->
  <!--<value>-->
  <!--jdbc:mysql://localhost:3306/test?useUnicode=true&amp;characterEncoding=utf-8-->
  <!--</value>-->
  <!--</property>-->
  <!--数据库的用户名 -->
  <!--<property name="username">-->
  <!--<value>root</value>-->
  <!--</property>-->
  <!--数据库的密码 -->
  <!--<property name="password">-->
  <!--<value>111</value>-->
  <!--</property>-->
  <!--</bean>-->


  <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
  <property name="driverClass" value="com.mysql.jdbc.Driver"/>
  <property name="jdbcUrl" value="jdbc:mysql://localhost:3306/mydatadb"/>
  <property name="user" value="root"/>
  <property name="password" value="3958050"/>
  <property name="minPoolSize" value="6"/>
  <property name="maxPoolSize" value="10"/>
  <property name="maxIdleTime" value="300"/>
  <property name="acquireIncrement" value="3"/>
  <property name="initialPoolSize" value="4"/>
  </bean>

  <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
  <property name="dataSource" ref="dataSource"/>
  <property name="mappingResources">
  <list>
  <value>mycom/test.hbm.xml</value>
   


  </list>
  </property>
  <property name="hibernateProperties">
  <props>
  <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
  <prop key="hibernate.connection.autocommit">true</prop>
  <prop key="hibernate.show_sql">true</prop>