麻烦老师帮我看看问题出在哪
之前把catelog写成catelog,刚刚全部修改过来了但还是出错,我实在找不到错误在哪,错误信息提示的地方我就是找不到,下面我放出报错可能发生的地方老师看看,就是找不到这个catelog在哪,因为报错显示sql问题,我就只放DAO了
package com.imooc.icake.dao; import com.imooc.icake.entity.Catalog; import com.imooc.icake.entity.Catalog; import org.apache.ibatis.annotations.*; import java.util.List; public interface CatalogDao { @Insert("<script>" + "insert into catalog(title,pid,info) values" + "<foreach collection='list' item='catalog' separator=','>" + "(#{catalog.title},#{catalog.pid},#{catalog.info})" + "</foreach>"+ "</script>") @Options(useGeneratedKeys = true,keyProperty = "id") void batchInsert(List<Catalog> list); @Delete("delete from catalog where id=#{id}") void delete(int id); @Select("select * from catalog where id = #{id}") @Results(id="all",value={ @Result(column = "id", property = "id", id = true), @Result(column = "title", property = "title"), @Result(column = "info", property = "info"), @Result(column = "id", property = "children", many = @Many(select = "selectByPid")) }) Catalog select(int id); @Select("select * from catalog where pid=#{pid}") @ResultMap("all") List<Catalog> selectByPid(int pid); }
package com.imooc.icake.dao; import com.imooc.icake.entity.Cake; import org.apache.ibatis.annotations.*; import java.util.List; public interface CakeDao { @Insert("insert into cake(title,cid,image_path,price,taste,sweetness,weight,size,material,status) values(#{title},#{cid},#{imagePath},#{price},#{taste},#{sweetness},#{weight},#{size},#{material},#{status})") @Options(useGeneratedKeys = true, keyProperty = "id") void insert(Cake cake); @Update("update cake set title=#{title},cid=#{cid},image_path=#{imagePath},price=#{price},taste=#{taste},sweetness=#{sweetness},weight=#{weight},size=#{size},material=#{material},status=#{status} where id=#{id}") void update(Cake cake); @Delete("delete from cake where id=#{id}") void delete(int id); @Select("select c.*,ca.title ctitle from cake c left join catalog ca on c.cid=ca.id where c.id=#{id}") @Results(id="all",value = { @Result(id = true,column = "id",property = "id"), @Result(column = "title",property = "title"), @Result(column = "cid",property = "cid"), @Result(column = "image_path",property = "imagePath"), @Result(column = "price",property = "price"), @Result(column = "taste",property = "taste"), @Result(column = "sweetness",property = "sweetness"), @Result(column = "weight",property = "weight"), @Result(column = "size",property = "size"), @Result(column = "material",property = "material"), @Result(column = "status",property = "status"), @Result(column = "ctitle",property = "catalog.title") }) Cake select(int id); @Select("select c.*,ca.title ctitle from cake c left join catalog ca on c.cid=ca.id") @ResultMap("all") List<Cake> selectAll(); }
Caused by: org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'icake.catelog' doesn't exist ### The error may exist in com/imooc/icake/dao/CatelogDao.java (best guess) ### The error may involve com.imooc.icake.dao.CatelogDao.select-Inline ### The error occurred while setting parameters ### SQL: select * from catelog where id = ? ### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'icake.catelog' doesn't exist
30
收起
正在回答 回答被采纳积分+1
3回答
3. Java 数据库开发与实战应用
- 参与学习 人
- 提交作业 357 份
- 解答问题 8016 个
本阶段将带你学习MySQL数据库,JDBC接口,MyBatis框架等,带你掌握的数据的存放和管理。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星