我用的ssh2做了个小项目
做更新数据时查询出来的list转换为对象时出错
以下是我的beanpackage com.cye.model;import java.util.Date;public class DaNews {
private DaBase daBase;
private int newsId;
private String newsTitle;
private String keywords;
private String description;
private String newsContent;
private Date newsDate;
private int newsCount;
private String username;
private String newsSource;
private String newsType;
private String newsChannel;
private int newsPath;
private String newsLanmu;

public DaBase getDaBase() {
return daBase;
}
public DaNews(){

} public DaNews(int newsId, String newsTitle, String newsContent,
Date newsDate, int newsCount, String username, String newsSource,
String newsType, String newsChannel, int newsPath, String newsLanmu) {
super();
this.newsId = newsId;
this.newsTitle = newsTitle;
this.newsContent = newsContent;
this.newsDate = newsDate;
this.newsCount = newsCount;
this.username = username;
this.newsSource = newsSource;
this.newsType = newsType;
this.newsChannel = newsChannel;
this.newsPath = newsPath;
this.newsLanmu = newsLanmu;
}
public DaNews(DaBase daBase, int newsId, String newsTitle, String keywords,
String description, String newsContent, Date newsDate,
int newsCount, String username, String newsSource, String newsType,
String newsChannel, int newsPath, String newsLanmu) {
super();
this.daBase = daBase;
this.newsId = newsId;
this.newsTitle = newsTitle;
this.keywords = keywords;
this.description = description;
this.newsContent = newsContent;
this.newsDate = newsDate;
this.newsCount = newsCount;
this.username = username;
this.newsSource = newsSource;
this.newsType = newsType;
this.newsChannel = newsChannel;
this.newsPath = newsPath;
this.newsLanmu = newsLanmu;
}
public void setDaBase(DaBase daBase) {
this.daBase = daBase;
}
public int getNewsId() {
return newsId;
}
public void setNewsId(int newsId) {
this.newsId = newsId;
}
public String getNewsTitle() {
return newsTitle;
}
public void setNewsTitle(String newsTitle) {
this.newsTitle = newsTitle;
}
public String getKeywords() {
return keywords;
}
public void setKeywords(String keywords) {
this.keywords = keywords;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getNewsContent() {
return newsContent;
}
public void setNewsContent(String newsContent) {
this.newsContent = newsContent;
}
public Date getNewsDate() {
return newsDate;
}
public void setNewsDate(Date newsDate) {
this.newsDate = newsDate;
}
public int getNewsCount() {
return newsCount;
}
public void setNewsCount(int newsCount) {
this.newsCount = newsCount;
} public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getNewsSource() {
return newsSource;
}
public void setNewsSource(String newsSource) {
this.newsSource = newsSource;
}
public String getNewsType() {
return newsType;
}
public void setNewsType(String newsType) {
this.newsType = newsType;
}
public int getNewsPath() {
return newsPath;
}
public void setNewsPath(int newsPath) {
this.newsPath = newsPath;
}
public String getNewsChannel() {
return newsChannel;
}
public void setNewsChannel(String newsChannel) {
this.newsChannel = newsChannel;
}
public String getNewsLanmu() {
return newsLanmu;
}
public void setNewsLanmu(String newsLanmu) {
this.newsLanmu = newsLanmu;
}
}
查询的语句
public DaNews readCount(int id) {
List<DaNews> list = this.getSession().createQuery("select new DaNews(newsId, newsTitle," +
"newsContent, newsDate," +
"newsCount, username, newsSource, newsType,newsChannel, newsPath, newsLanmu) " +
"from DaNews dn where dn.newsPath = "+id).list();
log.debug("===查询=====");
return (DaNews)list;
}