Mapper method com.xxxxx has an unsupported return type: class com.xxx

写了半天报了这个错误,Mapper method com.xxxxx has an unsupported return type: class com.xxx
具体的:
org.apache.ibatis.binding.BindingException: Mapper method ‘com.cxj.dao.NewDao.dynamicTrimTest1’ has an unsupported return type: class com.cxj.pojo.NewsEntity
at org.apache.ibatis.binding.MapperMethod.rowCountResult(MapperMethod.java:109)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:62)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59)
at com.sun.proxy.$Proxy5.dynamicTrimTest1(Unknown Source)
at com.cxj.test.TestSQL.testtrim2(TestSQL.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
原因是类型不配,用的是update SQL语句,他的返回值只能是int类型,不能是其他的,检查dao层语句是否为int,再看xml文件的parameterTYpe是否为integer,然后是测试语句的调用处为int。
详细代码:
dao层:

public **int** dynamicTrimTest1(NewsEntity newsEntity );

xml文件在这里插入代码片


		update tb_news
		
		    
		        title=#{title}, 
		    
		    
		        author=#{author}, 
		    
		

test语句:

@Test
	public void testtrim2() {
		SqlSession session=MyBatisUtils.getSession();
		NewDao newDao=session.getMapper(NewDao.class);
		NewsEntity newsEntity =new NewsEntity();
		newsEntity.setTitle("very帅");
		newsEntity.setId(2);
		**int** list=newDao.dynamicTrimTest1(newsEntity);;
		System.out.println("更新成功"+list+"条");
		//打开事务
		session.commit();
		//关闭事务
		session.close();
	}

java类:

public class NewsEntity {
	private Integer Id;

	private String author;//作者

	private String content;//内容

	private String title;//标题

	private String owner;//所有权

	public Integer getId() {
		return Id;
	}

	public void setId(Integer id) {
		Id = id;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getOwner() {
		return owner;
	}

	public void setOwner(String owner) {
		this.owner = owner;
	}
	
	@Override
	public String toString() {
		return "NewsEntity [Id=" + Id + ", author=" + author + ", content=" + content + ", title=" + title + ", owner="
				+ owner + "]";
	}
}

希望以上的经验可以帮助大家。

你可能感兴趣的:(后端)