日期:2014-05-19  浏览次数:20634 次

getHibernateTemplate().save() 不保存数据
Java code

<!--spring配置-->
<?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-2.5.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
    <bean id="propertyConfigurer"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:jdbc.properties</value>            
            </list>
        </property>
    </bean>
    <!-- 连接池dbcp -->
    <bean id="dataSource"
        class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName"
            value="${driverClassName}">
        </property>
        <property name="url"
            value="${url}">
        </property>
        <property name="username" value="${username}"></property>
        <property name="password" value="${password}"></property>
        <!-- 最大 连接数 -->
        <property name="maxActive" value="100"></property>
        <!--最大空闲连接 -->
        <property name="maxIdle" value="30"></property>
        <!-- 最大等待连接 -->
        <property name="maxWait" value="500"></property>
        <!-- 默认最大提交,TRUE,每操作一次数据库自动提交 
        <property name="defaultAutoCommit" value="true"></property>-->
    </bean>
    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"></property>
        <property name="hibernateProperties">
            <props>
                <!--ernate方言-->
                <prop key="hibernate.dialect">
                    ${dialec} 
                </prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.hbm2ddl.auto">none</prop>
                <prop key="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</prop>
                <!--统计信息 -->
                <prop key="generate_statistics">false</prop>
                <!-- Query查询时也用二级缓存 
                <prop key="cache.use_query_cache">true</prop>-->
            </props>
        </property>
        <!--  <property name="mappingResources">
            <list>
            <value>com/test/bean/User.hbm.xml</value>
            </list>
            </property>-->
        <property name="configLocation">
            <value>classpath:hibernate.cfg.xml</value>
        </property>
        
    </bean>
    <!-- 配置事务管理器 -->
    <bean id="transactionManager"
        class="org.springframework.orm.hibernate3.HibernateTransactionMan