gaoliang00 2009-10-16 11:27 采纳率: 100%
浏览 573
已采纳

我的删除执行不报错,可是数据库中的记录没有删掉,伤脑筋啊!!

dao的删除代码:

public class ScoreDaoHibernate extends HibernateDaoSupport implements ScoreDao {

public void delete(String id) {
    Score dd=(Score)this.getHibernateTemplate().get(Score.class, id);
    System.out.println(dd.getCourseName());
    this.getHibernateTemplate().delete(dd);

    //throw new RuntimeException();
    }

    }

测试文件代码:

public class transactiontest extends AbstractTransactionalDataSourceSpringContextTests {

private ScoreDao scoreDao;

protected String[] getConfigLocations() {
    return new String[] { "classpath:applicationContextoracle.xml" };
}

public void onSetUpBeforeTransaction() throws Exception {
    scoreDao = (ScoreDao) applicationContext.getBean("scoreDao");
}

public void testCjScoreDTODao() {
      scoreDao.delete("3");
     //List<Score> aa=scoreDao.findAllBySno("0403010616");
     //System.out.println(aa.size());
     System.out.println("-----------------");

}

}

配置文件代码:

<?xml version="1.0" encoding="UTF-8"?>
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.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">

<bean id="dataSource"
    class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName"
        value="oracle.jdbc.driver.OracleDriver">
    </property>
    <property name="url"
        value="jdbc:oracle:thin:202.118.121.112:1521:orcl">
    </property>
    <property name="username" value="scott"></property>
    <property name="password" value="gl"></property>
</bean>

<bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource">
        <ref bean="dataSource" />
    </property>
    <property name="mappingResources">
        <list>
            <value>com/gl/model/Score.hbm.xml</value>
            <value>com/gl/model/Userpassword.hbm.xml</value>
            <value>com/gl/model/Xuanke.hbm.xml</value>

        </list>
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</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>



<!-- the transactional semantics... -->

<tx:attributes>

  <tx:method name="insert*" propagation="REQUIRED"/>
  <tx:method name="update*" propagation="REQUIRED"/>
  <tx:method name="delete*" propagation="REQUIRED"/>
  <tx:method name="*" read-only="true"/>
</tx:attributes>

/tx:advice

aop:config


/aop:config

<bean id="scoreDao" class="com.gl.dao.hibernate.ScoreDaoHibernate"
    abstract="false" lazy-init="default" autowire="default"
    dependency-check="default">
    <property name="sessionFactory">
        <ref bean="sessionFactory" />
    </property>
</bean>

请大家帮我看看是什么原因啊????

  • 写回答

3条回答 默认 最新

  • wanghaolovezlq 2009-10-16 11:29
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!