code=SQL]
select p.*,m.city from party p inner join message m on party.itemid=message.itemid where City='上海'[/code]把这句改成hql,谢谢

解决方案 »

  1.   

    select * from Party p left join p.message m where p.itemid = m.itemid and city = '上海'SQL改HQL这种带join的,你自己的PO要设好关联才可以的
      

  2.   

    from party p inner join message m on party.itemid=message.itemid where City='上海' 
      

  3.   

    select p.*,m.city from party p inner join message m on party.itemid=message.itemid where City='上海' 不会,UP!
      

  4.   

    应该是这样 后面and m.city才对
    select * from Party p left join p.message m where p.itemid = m.itemid and m.city = '上海' 
      

  5.   


    select p.*,m.city from Part p inner join Message m on Part.itemid=m.itemid where City='上海' --这里 Part    Message 是javabean , Part.itemid(这里是类里的字段)
      

  6.   

    楼主弄明白所查的字段是model层中类的字段,而不是表中的字段,这就行了~~呵呵
      

  7.   

    select p.*,m.city from party p,message m where p.itemid = m.itemid and m.city=上海
      

  8.   

    第一,没有配置文件怎么改成HQL呀。似乎没有必要改HQL,使用如下方式就行了:select {p.*},{m.city} from party p inner join message m on party.itemid=message.itemid where City='上海'然后配置实体别名就可以了。原来有一种直接类实体填充方法,但是官方不给接口api,只给了如下形式,估计不推荐使用吧!
    public SQLQuery createSQLQuery(String queryString)
                            throws HibernateException
      

  9.   

    select Party,Message.city from Party , Message 
    where Party.itemid=Message.itemid and Message.city='上海' 
      

  10.   

    select p,m.city from Party p,Message m where m.itemId = p.itemId and m.city='上海'表名改成类名,字段名改成属性名
    前提你配置文件没问题另外一楼朋友。直接写*会出错吧
      

  11.   


    楼上的我看行,当然select可以省去了
      

  12.   

    select p from party where p.message.city='上海'
      

  13.   

    select p,m.city from Party p,Message m where m.itemId = p.itemId and m.city='上海'