Duplicated entries on using ManyToMany
Hi,
I'm working with a legacy database, that's why the database schema isn't that
fine. I'm using following classes:
Code:
@Entity
@Table(name = "TS_STATI")
class Status {
@Id
@Column(name = "STATUS_ID")
private Long id;
@ManyToMany
@JoinTable(name = "TEXT2STATI2NAME",
joinColumns = {
@JoinColumn(name = "MAP_ID")
},
inverseJoinColumns = {
@JoinColumn(name = "TEXT_ID", referencedColumnName = "TEXT_ID")
})
private List<TextResource> nameLocalized;
}
@Entity
@Table(name = "TEXT_RESSOURCE")
class TextResource {
@Id
@Column(name = "ROWID")
private String id;
@Column(name = "TEXT_ID")
private Long textId;
@Column(name = "SPRACHE")
@Type(type = "LocaleType")
private Locale locale;
@Column(name = "TEXT")
private String text;
}
As can imagine, the TextResource contains translations.
When i quering
Code:
from Status
the status object - in one of ten cases -
the TextResource list contains duplicate entries (e.g. three times the french
translation) and not one for each language.
The generated sql works fine.
Code:
SELECT namelocali0_.map_id AS map1_1_, namelocali0_.text_id AS text2_1_,
textresour1_.ROWID AS rowid1_132_0_,
textresour1_.sprache AS sprache132_0_, textresour1_.text AS text132_0_,
textresour1_.text_id AS text4_132_0_
FROM text2stati2name namelocali0_, text_ressource textresour1_
WHERE namelocali0_.text_id = textresour1_.text_id(+)
AND namelocali0_.map_id = ?
Is it a hibernate bug or did I configure it in a wrong way. Maybe it has to
do with the ROWID or... Of course it is also not a pure m:n relation. It is
something like 1:1:n.
Hibernate Version: 3.2.6ga, Database Oracle: 9.
I hope you can help me.
Thank you in advance.
Best regards, Michi