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();
} |
Partager