三张表查询出现问题

换一个数据测就好 代码没有错 就是不适用于全部数据

原因是太多数据了 map放不完了

解决方法  1.sql语句继续升级做组合

              2.建一个实体类去装这些属性

org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 2

==>  Preparing: select * from timetable tt inner join teacher t on tt.tid=t.tid inner join course c on tt.cid=c.cid where tt.cid=?
==> Parameters: c01(String)
<==    Columns: tid, cid, classroom, classtime, flag, tid, tname, tpassword, tright, flag, cid, cname, flag
<==        Row: 1, c01, B-911, 星期一    1-2节, 1, 1, teacherZhang, 123, 1, 1, c01, JavaWeb, 1
<==        Row: 2, c01, B-913, 星期一    1-2节, 1, 2, teacherLi, 1111, 1, 1, c01, JavaWeb, 1
<==      Total: 2
Resetting autocommit to true on JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@78383390]
Closing JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@78383390]
Returned connection 2016949136 to pool.

org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 2

    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:80)
    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:87)
    at org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:145)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:86)
    at jdk.proxy2/jdk.proxy2.$Proxy12.queryInFoByCid(Unknown Source)
    at cn.edu.lingnan.Service.CourseServiceImpl.queryInFoByCid(CourseServiceImpl.java:144)
    at cn.edu.lingnan.test.CourseMapperTest.queryInFoByCidTest(CourseMapperTest.java:73)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    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.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
    at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)

你可能感兴趣的:(apache)