I am reversing engeneering a MySQL database, to create JPA POJOS from tables. I use the Eclipse Plugin for hibernate tools
There are to main tables, "person" and "place", and a pure relation table "person_place". Reverse engeneering creates the following POJOs
Code:
public class Person implements java.io.Serializable {
private Long id;
private String name;
private Set<Place> places = new HashSet<Place>(0);
.... getters-setters
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "persona_puesto", catalog = "test", joinColumns = { @JoinColumn(name = "ID_PERSONA", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "ID_PUESTO", nullable = false, updatable = false) })
public Set<Place> getPlaces() {
return this.places;
}
public void setPlaces(Set<Place> places) {
this.places = places;
}
}
public class Place implements java.io.Serializable {
private Long id;
private String dePlace;
private Set<Person> persons = new HashSet<Person>(0);
.... getters-setters
@ManyToMany(fetch = FetchType.LAZY, mappedBy = "places")
public Set<Person> getPersons() {
return this.persons;
}
public void setPersons(Set<Person> persons) {
this.persons = persons;
}
}
The many-to-many relation is mapped correctly, but I need to change the name of the many to many relations and I can't find a way. I found easy to change names with hibernate.reveng.xml in @ManyToOne or @OneToMany but it seems impossible in @ManyToMany. Is it possible to do that?