2

我无法将此表达式转换为 Criteria 表达式:

SELECT profile_profiles.profile_sup_id 
  FROM profil
  INNER JOIN profile_profiles ON profile_profiles.profile_id = profil.id 
        AND profil.id = 4

任何人都可以帮忙吗?

我有一张桌子'Profil'多对多和refelxive

配置文件 1 --- profile_profiles --- 配置文件 2

public class Profil implements Serializable {

    private static final long serialVersionUID = 1L;
    private Long id;
    private String libelle;
    private Set<Profil> profiles = new HashSet<Profil>(0);
...
}

血红蛋白

<set name="profiles" table="profile_profiles" cascade="all">
            <key column="profile_id" />
            <many-to-many column="profile_sup_id" class="com.steriamedshore.proboard.model.referentiel.Profil" />
        </set>
4

2 回答 2

0

thank you very much @JB Nizet

I did actually find the solution yesterday :

hibernateCriteria.createCriteria("profil").createAlias("profiles", "ps").add( Restrictions.eq("ps.id",superieurCriteria.getProfilId()) ) ;

peace.

于 2012-08-01T10:10:29.887 回答
0
Criteria c = session.createCriteria(Profil.class, "profil");
c.createAlias("profil.profiles", "supProfil");
c.add(Restrictions.eq("profil.id", 4);
c.setProjection(Projections.property("supProfil.id"));

上面应该,AFAIK,从连接表到配置文件表的附加连接,但它应该返回与您的 SQL 查询相同的内容。

于 2012-07-31T17:07:55.287 回答