1.<select id="count" resultClass="int">
select count(*) from Site_Info
</select>
基类中用的selectByPage时用到totalrecord的查询
2.<selectKey resultClass="java.lang.Integer" keyProperty="siteId">
<![CDATA[SELECT LAST_INSERT_ID() AS ID ]]>
</selectKey>
insert语句后面需要添加自动增长的主键(int)
3.记得注入service层以及Dao
<bean name="siteDao" class="com.ruangao.admin.dao.impl.SiteInfoImpl">
<property name="sqlMapClientTemplate" ref="sqlMapClientTemplate" />
<property name="sqlmapNamespace" value="SiteInfo" />
</bean>
4.在表单输入区中记得加入隐藏输入ID
<input type="hidden" id="siteId" name="siteId" />
以方便查询当前表的主键
5.查询时一般是
Page page = new Page();
page.setCurrentPageIndex(this.currentPageIndex);
page.setPageSize(this.pageSize);
SqlParam sqlParam = new SqlParam();
sqlParam.setPage(page);
page = adminZoneService.queryAll(sqlParam);
this.setModelList(page.getResult());
return Action.SUCCESS;
封装好类(设计模式好!)。
6.一般在spring配置bean的时候,注意点击链接的property,看是否能链接到。如果没有的话,就要及时的检查,免得下次改的时候还要重复的检查,严谨!!!
select count(*) from Site_Info
</select>
基类中用的selectByPage时用到totalrecord的查询
2.<selectKey resultClass="java.lang.Integer" keyProperty="siteId">
<![CDATA[SELECT LAST_INSERT_ID() AS ID ]]>
</selectKey>
insert语句后面需要添加自动增长的主键(int)
3.记得注入service层以及Dao
<bean name="siteDao" class="com.ruangao.admin.dao.impl.SiteInfoImpl">
<property name="sqlMapClientTemplate" ref="sqlMapClientTemplate" />
<property name="sqlmapNamespace" value="SiteInfo" />
</bean>
4.在表单输入区中记得加入隐藏输入ID
<input type="hidden" id="siteId" name="siteId" />
以方便查询当前表的主键
5.查询时一般是
Page page = new Page();
page.setCurrentPageIndex(this.currentPageIndex);
page.setPageSize(this.pageSize);
SqlParam sqlParam = new SqlParam();
sqlParam.setPage(page);
page = adminZoneService.queryAll(sqlParam);
this.setModelList(page.getResult());
return Action.SUCCESS;
封装好类(设计模式好!)。
6.一般在spring配置bean的时候,注意点击链接的property,看是否能链接到。如果没有的话,就要及时的检查,免得下次改的时候还要重复的检查,严谨!!!
数据库操作与Spring框架整合技术
本文详细介绍了在数据库操作中使用Spring框架的整合技术,包括如何在Service层注入Dao层,实现分页查询,自动获取主键,以及在表单中添加隐藏输入ID等关键步骤。同时强调了配置Bean时的注意事项,确保代码的严谨性和效率。
155

被折叠的 条评论
为什么被折叠?



