@Override
public ArrayList<ContentExt> findListBaseContentExt(int ChannelId,
int startPage ,int endPage) {
String sql = " select contentext1_.content_id , contentext1_.title ,contentext1_.short_title , "+
"contentext1_.description ,contentext1_.author ,contentext1_.origin , " +
"contentext1_.origin_url , contentext1_.release_date ,contentext1_.media_path , "+
"contentext1_.media_type , contentext1_.title_color ,contentext1_.is_bold , "+
"contentext1_.title_img ,contentext1_.content_img ,contentext1_.type_img , " +
" contentext1_.type_img118 ,contentext1_.type_img170 ,contentext1_.type_img900 ,"+
" contentext1_.link ,contentext1_.tpl_content ,contentext1_.need_regenerate , "+
" channel2_.channel_path "+
" from " +
" jc_content content0_ " +
" inner join "+
" jc_content_ext contentext1_ "+
" on content0_.content_id=contentext1_.content_id " +
" inner join " +
" jc_channel channel2_ "+
" on content0_.channel_id=channel2_.channel_id, " +
" jc_channel channel3_ " +
" where " +
" ( " +
" channel2_.lft between channel3_.lft and channel3_.rgt " +
" ) "+
" and content0_.site_id=channel3_.site_id " +
" and channel3_.channel_id= " + ChannelId
+ " and content0_.status=2 " +
" order by " +
" contentext1_.release_date desc limit " + startPage+","+endPage ;
List<ContentExt> contextExtList = new ArrayList<ContentExt> ();
Query query = getSession().createSQLQuery(sql);
List list = query.list();
System.out.println(list.size());
Iterator iter = list.iterator();
SimpleDateFormat dateformat=new SimpleDateFormat("yyyyMMdd");
while(iter.hasNext()){
Object[] obj = (Object[])iter.next();
ContentExt contentExt = new ContentExt();
int id = (Integer)obj[0];
String title=(String)obj[1];
String short_title=(String)obj[2];
String description=(String)obj[3];
String author=(String)obj[4];
String origin=(String)obj[5];
String origin_url=(String)obj[6];
Date release_date=(Date)obj[7];
String media_path=(String)obj[8];
String media_type=(String)obj[9];
String title_color=(String)obj[10];
// String is_bold=(String)obj[11];
String title_img=(String)obj[12];
String content_img=(String)obj[13];
String type_img=(String)obj[14];
String type_img118=(String)obj[15];
String type_img170=(String)obj[16];
String type_img900=(String)obj[17];
String link=(String)obj[18];
String tpl_content=(String)obj[19];
// Boolean need_regenerate=(Boolean)obj[20];
String channel_path=(String)obj[21];
contentExt.setId(id);
contentExt.setTitle(title);
contentExt.setShortTitle(short_title);
contentExt.setDescription(description);
contentExt.setAuthor(author);
contentExt.setOrigin(origin);
contentExt.setOriginUrl(origin_url);
contentExt.setReleaseDate(release_date);
contentExt.setMediaPath(media_path);
contentExt.setMediaType(media_type);
contentExt.setTitleColor(channel_path); //channel_path
contentExt.setTypeImg(type_img);
String releaseDate=dateformat.format(release_date);
contentExt.setLink(releaseDate); //日期
contentExt.setTplContent(tpl_content);
// contentExt.setNeedRegenerate(need_regenerate);
contextExtList.add(contentExt);
System.out.println("id:"+id +";title:"+title +";release_date" +release_date);
}
return (ArrayList<ContentExt>) contextExtList;
}
随笔 -Hibernate Query查找
原创文章标签 Hibernate Query查找 文章分类 前端开发
©著作权归作者所有:来自51CTO博客作者v512345的原创作品,请联系作者获取转载授权,否则将追究法律责任
![](https://ucenter.51cto.com/images/noavatar_middle.gif)
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Hibernate query by Example
e="true" select-before-update="true">
hibernate query string integer payment