[Criteria][One-to-Many][FetchMode.EAGER] bug de Hibernate?
Bonjour,
Après avoir résolu mon problème de mapper les maps par annotation http://www.developpez.net/forums/d74...ersister-maps/, je decouvre un bug de recherche par criteria.
La recherche par criteria retourne des doublons alors que la recherche par query retourne le bon résultat.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
class Entity {
private OtherEntitty otherEntity;
private Map<String, String> map;
@CollectionOfElements(fetch=FetchType.EAGER) // mapper une collection de type primitif
@JoinTable(name="map")
@JoinColumn(name="entity")
@MapKey(columns=@Column(name="name"))
@Column(name="value")
//@Lob // si value est du type clob
public Map<String, String> getMap() {
//getter
}
...
// retourne des doublons
hibernateTemplate.createCriteria(Entity.class).add(Restrictions.eq("otherEntity", otherEntity)).list();
// retourne bon résultat
hibernateTemplate.createQuery("from Entity e where e.otherEntity = :otherEntity").setEntity("otherEntity", otherEntity).list();
} |
Alors, lorsque j'enlève fetch=FetchType.EAGER de @CollectionOfElements, la recherche par criteria ne retourne plus de doublon.
Est ce que c'est un bug ou un comportement normal de Hibernate?
Merci pour votre lumière!