严重: IllegalArgumentException in class

武汉泰伦特世纪 2008-07-23 11:44:01
Hibernate: select news0_.NewsID as NewsID1_, news0_.AuthorNickName as AuthorNi2_1_, news0_.NewsTitle as NewsTitle1_, news0_.NewsContent as NewsCont4_1_, news0_.IssueTime as IssueTime1_, news0_.ClickNum as ClickNum1_, news0_.NewsTypeID as NewsTypeID1_ from tiantiannews.news news0_ inner join tiantiannews.newscomments newscommen1_ on news0_.NewsID=newscommen1_.NewsID where news0_.NewsTypeID=? order by newscommen1_.comTime desc limit ?
2008-7-23 22:48:46 org.hibernate.property.BasicPropertyAccessor$BasicGetter get
严重: IllegalArgumentException in class: com.hehe.hibernate.model.Newstype, getter method of property: newsTypeId
org.springframework.orm.hibernate3.HibernateSystemException: IllegalArgumentException occurred calling getter of com.hehe.hibernate.model.Newstype.newsTypeId; nested exception is org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.hehe.hibernate.model.Newstype.newsTypeId
Caused by: org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of com.hehe.hibernate.model.Newstype.newsTypeId

-------------------------------------------

News类中:
private Newstype newsType;

public Newstype getNewsType() {
return this.newsType;
}

public void setNewsType(Newstype newsType) {
this.newsType = newsType;
}
news.hbm.xml中:
<many-to-one name="newsType" column="NewsTypeID"/>
news父类newstype类的xml:
<id name="newsTypeId" type="java.lang.Integer">
<column name="NewsTypeID" />
<generator class="native" />
</id>
...
<set name="news" inverse="true">
<key column="NewsTypeID"/>
<one-to-many class = "News"/>
</set>

---------------------------------
我查询的hql = "select news from News as news inner join news.newsComments as comment"+
" where news.newsType=?"+
" order by comment.comTime desc";
请问怎么解决啊?
都整一下午加一晚上了!
在线等待啊!
...全文
1786 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
哈哈,自己解决了。
我想到:HQL是不能以组件结束的,
大家看到没有,我的查询语句中有:where news.newsType
而配置文件中确设置newsType为一个News中的一个组件。
所以,我只将这个地方改为:where news.newsType.newsTypeId即可。
这样,就达到了HQL语法的要求:最终是应该对基本类型的操作!
wz436392521 2008-07-24
  • 打赏
  • 举报
回复
上面的说的没错啊
mike1980 2008-07-24
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 mike1980 的回复:]
com.hehe.hibernate.model.Newstype, getter method of property: newsTypeId

你的PO类Bean的get方法报错。
[/Quote]

get方法的参数报错。
mike1980 2008-07-24
  • 打赏
  • 举报
回复
com.hehe.hibernate.model.Newstype, getter method of property: newsTypeId

你的PO类Bean的get方法报错。

67,538

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧