rissqjwyk 2010-04-20 16:13
浏览 291
已采纳

hibernate getHibernateTemplate().save无任何异常,SQL里就是没数据

环境:myeclipse8.0,tomcat6.0,struts2,hibernate3.2,spring2.5,jndi
spring配制文件:
<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"></property>
    <property name="url"
        value="jdbc:sqlserver://localhost:1433;DatabaseName=huaman"></property>
    <property name="username" value="sa"></property>
    <property name="password" value="sa"></property>
    <property name="maxActive" value="100"></property>
    <property name="maxIdle" value="30"></property>
    <property name="maxWait" value="10000"></property>
    <property name="defaultAutoCommit" value="false"></property>
</bean>

<bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource"></property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
            <prop key="hibernate.show_sql">true</prop>
        </props>
    </property>
    <property name="mappingResources">
        <list>
            <value>com/huaman/entity/UserInfo.hbm.xml</value>
        </list>
    </property>
</bean>

<!-- TransactionManager --><!-- 注释1
<bean id="transactionManager"
    class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory">
        <ref local="sessionFactory" />
    </property>
</bean>
<bean id="transactionProxyFactoryBean" abstract="true"
    class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    <property name="transactionManager">
        <ref local="transactionManager" />
    </property>
    <property name="transactionAttributes">
        <props>
            <prop key="delete*">PROPAGATION_REQUIRED</prop>
            <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
            <prop key="select*">PROPAGATION_REQUIRED,readOnly</prop>
            <prop key="add*">PROPAGATION_REQUIRED</prop>
            <prop key="update*">PROPAGATION_REQUIRED</prop>
            <prop key="has*">PROPAGATION_REQUIRED,readOnly</prop>
            <prop key="is*">PROPAGATION_REQUIRED,readOnly</prop>
            <prop key="query*">PROPAGATION_REQUIRED,readOnly</prop>
        </props>
    </property>
</bean>

-->




<bean id="userBiz" class="com.huaman.biz.impl.UserBizImpl">
    <property name="userDao" ref="userDao"></property>
</bean>

<bean id="loginAction" class="com.huaman.action.user.UserInfoAction"
    scope="prototype">
    <property name="userBiz" ref="userBiz"></property>
</bean>

<bean id="registerAction" class="com.huaman.action.user.UserRegisterAction"
    scope="prototype">
    <property name="userBiz" ref="userBiz"></property>
</bean>


DAO:方法名addUser;super.getHibernateTemplate().save(userInfo);
在网上找了很多,改了半天就是不行,hibernate.xml里也有:true 。hibernate插入语句也能出来,死活就是不写进数据库。

  • 写回答

3条回答 默认 最新

  • 漩涡小强 2010-04-20 19:14
    关注

    把你的JAVA文件贴下看看

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 idea自动补全键位冲突
  • ¥15 iis10中如何阻止别人网站重定向到我的网站
  • ¥15 滑块验证码移动速度不一致问题
  • ¥15 定制ai直播实时换脸软件
  • ¥100 栈回溯相关,模块加载后KiExceptionDispatch无法正常回溯了
  • ¥15 Utunbu中vscode下cern root工作台中写的程序root的头文件无法包含
  • ¥15 麒麟V10桌面版SP1如何配置bonding
  • ¥15 Marscode IDE 如何预览新建的 HTML 文件
  • ¥15 K8S部署二进制集群过程中calico一直报错
  • ¥15 java python或者任何一种编程语言复刻一个网页