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

有关ibatis求助
请哪位高手看一下,错在哪里了
public void updateChannel(Channel c) {
try {
session.update(Channel.class.getName()+".updateChannel", c);
session.commit();
} catch (Exception e) {
e.printStackTrace();
session.rollback();
} finally{
session.close();
}
}

配置文件
	<update id="updateChannel" parameterType="Channel" >
update t_channel set name=#{name},description=#{description} where id=#{id}
</update>


junit测试
	@Test
public void testUpdateChannel() {
Channel c = channeldao.getChannelById(11);
c.setName("updatechannel");
channeldao.updateChannel(c);
}

出现的错误--------------------------------------------------
org.apache.ibatis.exceptions.PersistenceException
### Error updating database.  Cause: org.apache.ibatis.executor.ExecutorException: Executor was closed.
### The error may exist in com/test/cms/backmanager/DAO/implement/Channel.xml
### The error may involve com.test.cms.model.Channel.updateChannel
### The error occurred while executing an update
### Cause: org.apache.ibatis.executor.ExecutorException: Executor was closed.
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:123)
at com.test.cms.backmanager.DAO.implement.ChannelDaoForMybatisImpl.updateChannel(ChannelDaoForMybatisImpl.java:89)
at com.test.cms.backmanager.DAO.ChannelDAOTest.testUpdateChannel(ChannelDAOTest.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)