File f = new File(".")
String url = "jdbc:sqlite:" + f.getAbsolutePath() + "\\cw.db"
Class.forName("org.sqlite.JDBC")
Connection con = DriverManager.getConnection(url)
你写了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>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)