2019独角兽企业重金招聘Python工程师标准>>>
ibatis 主配置文件SqlMapConfig.xml
ArticleColumnDymanic配置文件:
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
select seq_article.nextVal from dual
insert into tb_article_columndymanic( i_id,vc_name,vc_url,vc_filePath,vc_file,b_content,vc_desc,i_num,d_createtime,i_createuser,d_lastmodtime,i_moduser,c_deleted,vc_version,vc_isnew,vc_id,vc_remark)
values (#id#,#name#,#servletUrl#,#filePath#,#file#,#content,handler=org.springframework.orm.ibatis.support.ClobStringTypeHandler#,#desc#,#num#,sysdate,#base.createUser#,sysdate,#base.modUser#,'0',#version#,#isnew#,
update tb_article_columndymanic
set vc_name=#name#,vc_url=#servletUrl#,vc_filePath=#filePath#,vc_file=#file#,
b_content=#content,handler=org.springframework.orm.ibatis.support.ClobStringTypeHandler#,vc_desc=#desc#,i_num=#num#,
d_lastmodtime=sysdate,i_moduser=#base.modUser#,
vc_version=#version#,vc_isnew=#isnew#,vc_id=#vid#,vc_remark=#remark#
where i_id=#id#
实体类:
public class ArticleColumnDymanic {
private String name="";
private String servletUrl="";
private String filePath="";
private String file="";
private String content="";
private String desc="";
private int num=0;
private Long version=new Long(1);
private String isnew="1";
private Long vid;
private String remark;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getServletUrl() {
return servletUrl;
}
public void setServletUrl(String servletUrl) {
this.servletUrl = servletUrl;
}
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
public String getFile() {
return file;
}
public void setFile(String file) {
this.file = file;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public Long getVersion() {
return version;
}
public void setVersion(Long version) {
this.version = version;
}
public String getIsnew() {
return isnew;
}
public void setIsnew(String isnew) {
this.isnew = isnew;
}
public Long getVid() {
return vid;
}
public void setVid(Long vid) {
this.vid = vid;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}
查询clob字段:
public List
{
List listm = this.dao.findForList("selectProductById", map);
if ((listm != null) && (listm.size() > 0)) {
for (int i = 0; i < listm.size(); ++i) {
HashMap hm = (HashMap)listm.get(i);
CLOB clob = (CLOB)hm.get("B_CONTENT");
try {
hm.put("B_CONTENT", ClobToString(clob));
}
catch (Exception e) {
e.printStackTrace();
}
}
}
return listm;
}
private static String ClobToString(CLOB clob) throws Exception {
String reString = "";
Reader is = clob.getCharacterStream();
BufferedReader br = new BufferedReader(is);
String s = br.readLine();
StringBuffer sb = new StringBuffer();
while (s != null) {
sb.append(s);
s = br.readLine();
}
reString = sb.toString();
return reString;
}