IBatis使用SQLite数据库,app.config中要怎么配置
1个回答
展开全部
你写了resultClass,所以返回结果就是Book这个类,你应该有配一个alias。这样写要求你的book类的每一个字段和数据库的字段拼写都一样(首字母小写)。要是要对应的话,要写关联查询的配置,你可以看下api文档,配置较为繁琐。类似这样:
<resultMap type="HrMenu" id="menuResultMap">
<id property="id" column="ID" />
<result property="name" column="name" />
<result property="url" column="url" />
<result property="parentid" column="parentid" />
<result property="level" column="level" />
<result property="seq" column="seq" />
<result property="butnstyle" column="butnstyle" />
<association property="parent" column="parentid" select="HrMenu.findMenuById"></association>
<collection property="child" column="id" select="HrMenu.findMenusByParentId"></collection>
</resultMap>
<!-- 查询菜单list -->
<select id="findMenuById" parameterType="int" resultMap="menuNavResultMap">
SELECT * FROM hr_menu where id=#{id} order by seq;
</select>
<!-- 查询菜单list -->
<select id="findMenusByParentId" parameterType="int" resultMap="menuResultMap">
SELECT * FROM hr_menu where parentid=#{id} order by seq asc;
</select>
<resultMap type="HrMenu" id="menuResultMap">
<id property="id" column="ID" />
<result property="name" column="name" />
<result property="url" column="url" />
<result property="parentid" column="parentid" />
<result property="level" column="level" />
<result property="seq" column="seq" />
<result property="butnstyle" column="butnstyle" />
<association property="parent" column="parentid" select="HrMenu.findMenuById"></association>
<collection property="child" column="id" select="HrMenu.findMenusByParentId"></collection>
</resultMap>
<!-- 查询菜单list -->
<select id="findMenuById" parameterType="int" resultMap="menuNavResultMap">
SELECT * FROM hr_menu where id=#{id} order by seq;
</select>
<!-- 查询菜单list -->
<select id="findMenusByParentId" parameterType="int" resultMap="menuResultMap">
SELECT * FROM hr_menu where parentid=#{id} order by seq asc;
</select>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询