How to join Multiple tables using hibernate criteria where entity relationship is not direct?

后端 未结 2 1886
庸人自扰
庸人自扰 2021-02-06 05:43

I have three entities. those are:

@Entity
public class Organization {
    @Id
    private long id;
    @Column
    priv         


        
2条回答
  •  旧时难觅i
    2021-02-06 05:50

    Another way

    public List getAccountListByOrgName(String name){
        return sessionFactory.getCurrentSession().createCriteria(Account.class)
                    .createAlias("book", "book")
                    .createAlias("book.organization", "organization")
                    .add(Restrictions.eq("organization.name", name))
                    .list();
    }
    

提交回复
热议问题