数据库连接正确可能是需要显示的去commit
你配置一下事务处理让他的commit为true了

解决方案 »

  1.   

    在你的<bean id="sf" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">下在加一个<property name="hibernateProperties">
    <props>
    <prop key="hibernate.connection.autocommit">true</prop>
    </props>
    </property>试试!!!!
      

  2.   

    很明显你的SAVE方法有异常是主键问题吧
      

  3.   

    <?xml version="1.0" encoding="GB2312"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"><beans> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
    <property name="driverClass">
    <value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>
    </property>
    <property name="jdbcUrl">
    <value>jdbc:microsoft:sqlserver://127.0.0.1:1433;databaseName=humanPER;</value>
    </property>
    <property name="user">
    <value>sa</value>
    </property>
    <property name="password">
    <value>sa</value>
    </property>
    <property name="maxPoolSize">
                <value>40</value>
            </property>
    <property name="minPoolSize">
                <value>1</value>
            </property>
    <property name="initialPoolSize">
                <value>1</value>
            </property>
    <property name="maxIdleTime">
                <value>20</value>
            </property>
    </bean>

    <bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource">
    <ref bean="dataSource" />
    </property>
    <property name="mappingResources">
    <list>
    <value>com/xin/hibernate/Human.hbm.xml</value>
    <value>com/xin/hibernate/Contact.hbm.xml</value>
    <value>com/xin/hibernate/Education.hbm.xml</value>
    <value>com/xin/hibernate/Job.hbm.xml</value>
    <value>com/xin/hibernate/Skill.hbm.xml</value>
    <value>com/xin/hibernate/Intent.hbm.xml</value>
    <value>com/xin/hibernate/HumanTable.hbm.xml</value>
    <value>com/xin/hibernate/Company.hbm.xml</value>
    <value>com/xin/hibernate/Declarable.hbm.xml</value>
    <value>com/xin/hibernate/Favorite.hbm.xml</value>
    <value>com/xin/hibernate/Message.hbm.xml</value>
    <value>com/xin/hibernate/Post.hbm.xml</value>
    <value>com/xin/hibernate/Resume.hbm.xml</value>
    </list>
    </property>
    <property name="hibernateProperties">
     <props>
                    <prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
                    <prop key="show_sql">true</prop>
                    <prop key="hibernate.hbm2ddl.auto">update</prop>
                    <prop key="hibernate.jdbc.batch_size">20</prop> 
                </props>
    </property>
    </bean>

    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
            <property name="sessionFactory">
              <ref local="sessionFactory"/>
            </property>
        </bean>
        
         <bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
        <!--  事务拦截器bean需要依赖注入一个事务管理器 -->
            <property name="transactionManager" ref="transactionManager"/>
         <property name="transactionAttributes">
        <!--  下面定义事务传播属性-->
        <props>
        <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
         <prop key="*">PROPAGATION_REQUIRED</prop>
        </props>
        </property>
    </bean>

    <bean id="manager" abstract="true">
            <property name="humanDAO">
                <ref bean="humanDAO"/>
            </property>
            <property name="contactDAO">
                <ref bean="contactDAO"/>
            </property>
            <property name="jobDAO">
                <ref bean="jobDAO"/>
            </property>
            <property name="intentDAO">
                <ref bean="intentDAO"/>
            </property>
            <property name="skillDAO">
                <ref bean="skillDAO"/>
            </property>
            <property name="educationDAO">
                <ref bean="educationDAO"/>
            </property>            
            <property name="humanTableDAO">
                <ref bean="humanTableDAO"/>
            </property>
            <property name="companyDAO">
                <ref bean="companyDAO"/>
            </property>
            <property name="declarableDAO">
                <ref bean="declarableDAO"/>
            </property>
            <property name="favoriteDAO">
                <ref bean="favoriteDAO"/>
            </property>
            <property name="messageDAO">
                <ref bean="messageDAO"/>
            </property>
            <property name="postDAO">
                <ref bean="postDAO"/>
            </property>
            <property name="resumeDAO">
                <ref bean="resumeDAO"/>
            </property>
    </bean>
    <bean id="humanManager" class="com.xin.service.HumanManager" parent="manager"/>
    <bean id="companyManager" class="com.xin.service.CompanyManager" parent="manager"/>

        <!-- 定义BeanNameAutoProxyCreator-->
        <bean class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
        <!--  指定对满足哪些bean name的bean自动生成业务代理 -->
        <property name="beanNames">
                <!--  下面是所有需要自动创建事务代理的bean-->
                <list>
                    <value>humanManager</value>
                    <value>companyManager</value>
                </list>
                <!--  此处可增加其他需要自动创建事务代理的bean-->
        </property>
            <!--  下面定义BeanNameAutoProxyCreator所需的事务拦截器-->
            <property name="interceptorNames">
                <list>
                    <!-- 此处可增加其他新的Interceptor -->
                    <value>transactionInterceptor</value> 
                </list>
            </property>
        </bean>
    </beans>
    (仅做参考)
    我觉得你既然已经选择了把hibernate交Spring托管了,何不把sessionFactory也由Spring来管理呢,这样我个人觉得不错。