Hi,
I have 3 tables :
- artist (PK = id_artist)
- song (PK = id_song)
- artist_has_song (FK = FK_artist_has_song and FK_song_belong_to_artist)
There is a many-to-many relation between artist and song.
I want to generate domain code and DAO from database using reverse engineering.
When I use hibernate-tools version 3.2.0.beta9a, I get the following code :
Code:
public class Artiste implements java.io.Serializable {
...
@ManyToMany(cascade={CascadeType.ALL}, fetch=FetchType.LAZY,
mappedBy="artistes")
public Set<Song> getSongs() {
return this.songs;
}
}
public class Song implements java.io.Serializable {
...
@ManyToMany(cascade={CascadeType.ALL}, fetch=FetchType.LAZY,
mappedBy="songs")
public Set<Artiste> getArtistes() {
return this.artistes;
}
}
Whereas I'd like to have this code :
Code:
public class Artiste implements java.io.Serializable {
...
@ManyToMany(mappedBy="artisteCollection")
private Set<Mxp4> mxp4Collection;
}
public class Song implements java.io.Serializable {
...
@ManyToMany
@JoinTable(name="artiste_has_song",
joinColumns=@JoinColumn(name="id_song"),
inverseJoinColumns=@JoinColumn(name="id_artiste"))
private Set<Artiste> artisteCollection;
}
I tried to configure it in a custom strategy and in a reveng.xml file but I didn't succeed in.
Do I have to change the pojo.ftl too?
I don't know what is the best way to do it.
Thanks for your help!
Gael