sql 语句 select * from product as p inner join storeinfodetail as sd on p.id=sd.product where p.name like  '%PS%'

解决方案 »

  1.   


    select p from product as p inner join storeinfodetail as sd on p.id=sd.product where p.name like '%PS%'product   storeinfodetail 都得是对象名
      

  2.   

    select * from product as p where p.id in(select product from storeinfodetail) and p.name like '%PS%' 弄错了 应该是这样
      

  3.   

    是对象 搞错了 这样写 出来的不是对象了 要出来product 对象
      

  4.   

    from product p join p.storeinfodetail where p.name like '%PS%';
    hibernate两表必须有管理关系!否则不可用join hql中join 不需要on 应为配置文件中定义了管理关系!
    我上面写的storeinfodetail 必须为product 的属性也就是说1-1 or 1-n关系!!
      

  5.   


    例:
    user.java
    public class User{
        private int id;
        private Set books =  new HashSet(0);
    ...get set
    }
    public class Book{
        private int id;
        private User user;
    ...get set
    }hql:from User a left join a.books where a.id=?