0

Hibernate バージョン 4.2 を使用しています

私は2つのエンティティを持っています。

@Entity
public class A {

   Long Id;
  @ManyToOne
   B b;

}

@Entity
public class B {
   Long Id;
   //There is no relation back here with any annotations to A, and can't add a @OneToMany
}

このような結果を得るために Hibernate Criteria を使用してクエリを実行することは可能ですか?

List<Map<B,List<A>>>? 結合か選択かは関係ありません。

私が結果に望むものの例:

A.id  B.id

1    1,2,3,4
2    
3    5
4    7
5 

//トリンド

4

2 に答える 2

0

Hibernate in Action を書いた Christian Bauer の助けを借りました。

Hibernate からの基準:

 List<Object[]> result =
                    session.createCriteria(A.class, "a")
                        .createAlias("b", "i", JoinType.RIGHT_OUTER_JOIN)
                        .setResultTransformer(PassThroughResultTransformer.INSTANCE)
                        .list();
于 2013-06-19T11:39:30.027 に答える