错哪了关系表中的那个id该如何表示?

来源:百度知道 编辑:UC知道 时间:2024/06/01 02:40:03
select m from Channel c,Module m,ChannelModule cm where c.channelId=cm.Channel.channelId and m.moduleId=cm.Module.moduleId and c.channelId=?" ,new Long(channelID));

org.hibernate.QueryException: could not resolve property: Channel of: com.superway.entity.ChannelModule [select m from com.superway.entity.Channel c,com.superway.entity.Module m,com.superway.entity.ChannelModule cm where c.channelId=cm.Channel.channelId and m.moduleId=cm.Module.moduleId and c.channelId=?]

你这是要select出什么呀?m是一个表,很显然的失误
你要select也只能是select出m.moduleld 或者m表下面的其它字段 你要是想把m表里的所以字段都映射出来你可以使用 m.*
还有一个问题 c.channelId=?" ,new Long(channelID));
后面的new Long(channelID)); 应该是前面那个?号的参数吧
不能这么写 你得这样:

sqlStr.setLong(new Long(channelID))