ibatis 配置文件及对应数据的格式…
2014-01-26 15:37
399 查看
有两个实体:
public class WatchType implements Serializable{
private Long watchTypeId;
private String watchTypeName;
private String description;
......
}
public class Result {
private Long resultId;
private String name;
private Long watchTypeId;
private WatchType allWatchType;
........
}
resultMap 配置如下(仅以查询为例)
<resultMap id="allWatchType"
class="cn.com.pattek.eneity.WatchType">
<result
property="watchTypeId" column="ID" />
<result
property="watchTypeName" column="NAME"/>
<result
property="description" column="DESCRIPTION"/>
</resultMap>
<select id="getWatchTypeStore"
resultMap="allWatchType" >
select * from
pm_watch_type
</select>
<resultMap id="result"
class="cn.com.pattek.eneity.Result">
<result
property="resultId" column="ID"/>
<result
property="name" column="NAME" />
<result
property="allWatchType.watchTypeId"
column="WATCH_TYPE_ID"/>
<result
property="allWatchType.watchTypeName" column="pmwtName"
/>
</resultMap>
<select id="getResultByCondition"
resultMap="result">
select * from(select a.*,rownum rn from(select
r.id,r.name
r.watch_type_id,pmwt.name pmwtName,
from pm_result r
left join pm_watch_type pmwt on
pmwt.id=r.watch_type_id
</select>
action中得到result对象的list集合,将该list放入jaon数据中:
Pagination p = new Pagination(start, limit, totalCount);
p.setList(resultList);
this.objectToJson(p);(其中Pagination是分页的类)
这样在页面中得到的数据格式如下:[{resultId:'',name:'',"allWatchType":{"description":"","watchTypeId":2,"watchTypeName":"全天节目监看"}}]
前台页面获得数据的方式(以ext
store为例):fileds中{‘resultId','name','allWatchType.watchTypeId','
allWatchType.watchTypeName'}即可获得watchType 的id、name
或:
{‘resultId','name','allWatchType'}
在column中的对应:{
header : '类型',
dataIndex : 'allWatchType' ,
align : 'center',
//加此render的目的是 判断allWatchType为空的条件,若用
allWatchType .watchTypeId会有空指针的错误
renderer :function(value, metadata, record){
if(value=="" || value == null){
return "";
}else{
return record.get(' allWatchType ').watchTypeId;
}
}
}
public class WatchType implements Serializable{
private Long watchTypeId;
private String watchTypeName;
private String description;
......
}
public class Result {
private Long resultId;
private String name;
private Long watchTypeId;
private WatchType allWatchType;
........
}
resultMap 配置如下(仅以查询为例)
<resultMap id="allWatchType"
class="cn.com.pattek.eneity.WatchType">
<result
property="watchTypeId" column="ID" />
<result
property="watchTypeName" column="NAME"/>
<result
property="description" column="DESCRIPTION"/>
</resultMap>
<select id="getWatchTypeStore"
resultMap="allWatchType" >
select * from
pm_watch_type
</select>
<resultMap id="result"
class="cn.com.pattek.eneity.Result">
<result
property="resultId" column="ID"/>
<result
property="name" column="NAME" />
<result
property="allWatchType.watchTypeId"
column="WATCH_TYPE_ID"/>
<result
property="allWatchType.watchTypeName" column="pmwtName"
/>
</resultMap>
<select id="getResultByCondition"
resultMap="result">
select * from(select a.*,rownum rn from(select
r.id,r.name
r.watch_type_id,pmwt.name pmwtName,
from pm_result r
left join pm_watch_type pmwt on
pmwt.id=r.watch_type_id
</select>
action中得到result对象的list集合,将该list放入jaon数据中:
Pagination p = new Pagination(start, limit, totalCount);
p.setList(resultList);
this.objectToJson(p);(其中Pagination是分页的类)
这样在页面中得到的数据格式如下:[{resultId:'',name:'',"allWatchType":{"description":"","watchTypeId":2,"watchTypeName":"全天节目监看"}}]
前台页面获得数据的方式(以ext
store为例):fileds中{‘resultId','name','allWatchType.watchTypeId','
allWatchType.watchTypeName'}即可获得watchType 的id、name
或:
{‘resultId','name','allWatchType'}
在column中的对应:{
header : '类型',
dataIndex : 'allWatchType' ,
align : 'center',
//加此render的目的是 判断allWatchType为空的条件,若用
allWatchType .watchTypeId会有空指针的错误
renderer :function(value, metadata, record){
if(value=="" || value == null){
return "";
}else{
return record.get(' allWatchType ').watchTypeId;
}
}
}
相关文章推荐
- iBatis 配置文件详解
- ORACLE 11G 数据文件头格式
- VS2013下 关于解决检测到 Mac 文件格式: 请将源文件转换为 DOS 格式或 UNIX 
- jxl导出excel出现“文件错误,可能某些数据格式已丢失"
- ALV 导出电子表格的文件格式…
- 使用ibatis框架配置文件的格式
- Spark1.5.2日志配置&数据文件清理
- 小技巧--高效编写IBATIS配置文件中的属性与字段对应映射关系
- PHPMyadmin&nbsp;配置文件详解(配置)
- IBatis的Mapper配置文件中使用大于号好小于号 :>和<
- 【原】Python3 下 MP3格式文件的ID…
- WebService处理大数据量数据出错:运行配置文件中指定的扩展时出现异常。 ---> 超过了最大请求长度。.
- JPA学习笔记---JPA实体Bean的建立+配置文件+junit测试+自动生成(对应实体Bean的)数据库表+插入数据
- RMAN&nbsp;恢复实际操作(模拟数据文件…
- vi&nbsp;转换文件格式
- Tomcat&nbsp;7&nbsp;配置数据源
- java 读取配置文件
- MAN&nbsp;恢复实际操作(模拟数据文件丢…
- mybatis配置文件发生异常:中元素内容必须由格式正确的字符数据或标记组成
- NHibernate 中 text 和 image 数据类型在配置文件中对应类型