[hibernate - jpa] @CollectionOfElements without create the apposite table
- by blow
Hi all.
I have this:
Municipality class
@Entity
public class Municipality implements Serializable {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
private String country;
private String province;
private String name;
@Column(name="cod_catasto")
private String codCatastale;
private String cap;
@CollectionOfElements
private List<Address> addressList;
public Municipality() {
}
...
Address class
@Embeddable
public class Address implements Serializable {
@ManyToOne(fetch=FetchType.LAZY)
@Cascade(CascadeType.SAVE_UPDATE)
private Municipality municipality;
@Column(length=45)
private String address;
public Address() {
}
...
Address is embedded in another class Person.
When i save an instance of Person, hibernate create 3 tables: PERSON, MUNICIPALITY and MUNICIPALITY_ADDRESSLIST.
MUNICIPALITY_ADDRESSLIST contains 2 fields: MUNICIPALITY_ID (FK) and STREET.
I don't want this table, i only want the ID of table MUNICIPALITY into table PERSON(that embeds Address), what should i do?
I tried to add @JoinTable in Municipality entity like this:
@CollectionOfElements
@JoinTable(name="person")
private List<Address> addressList;
It partially worked, but i cant choose the column name of table PERSON that contains ID of the table MUNICIPALITY, it is, by hibernate choose, simply "MUNICIPALITY_ID"...
Thbaks.