A: 

I'm not sure what the expected result is exactly (I'm too lazy to reproduce the case) but you should be able to derive the following sample:

@org.hibernate.annotations.CollectionOfElements(targetElement = java.lang.String.class)
@JoinTable( name="PHONE",joinColumns = @JoinColumn(name="STUDENT_ID"))
@Column(name="PHONE_NO")
public Set<String> getPhones() {
Pascal Thivent
I tried this: @CollectionOfElements @JoinTable(name="person", joinColumns=@JoinColumn(name="id_municipality")) private List<Address> addressList;But doesn't work properly
blow
I have edit my post.
blow
+1  A: 

blow, if you do not really want *MUNICIPALITY_ADDRESSLIST* Table, you should use @Transient instead of @CollectionOfElements

public class Municipality {

    @Transient
    private List<Address> addressList;

}

If you use @CollectionOfElements, Hibernate will always create *MUNICIPALITY_ADDRESSLIST* Table. If @Transient does not fullfil your needs, provide more info about what you want to get

UPDATE

According to info provided by yourself

Person has an @Embedded Address which has a @ManyToOne relationship with Municipality

public class Person {

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY) 
    private Long id;

    @Embedded
    private Address address;

}

Now, our Address

/*
 * @Embeddable class MUST implements Serializable
 */
@Embeddable
public class Address implements Serializable {

    @ManyToOne
    /*
     * If you are using Hibernate INSTEAD OF JPA
     * Prefer to use @Cascade Hibernate annotation, as shown bellow, 
     * instead of JPA cascade Attribute
     *
     * Also notice it can not be null - see nullable Attribute
     */   
    @Cascade(CascadeType.SAVE_UPDATE)
    @JoinColumn(name="MUNICIPALITY_ID", nullable=false)
    private Municipality municipality;

}

And Municipality (without ANY List of Address or Person)

public class Municipality {

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY) 
    private Long id;

}

As shown above, your DB structure should looks like

PERSON
ID
MUNICIPALITY_ID

MUNICIPALITY
ID

But whether Municipality has a List of Person as follows

public class Municipality {

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY) 
    private Long id;

    @OneToMany
    private List<Person> personList;

}

You will get The same structure shown above

But you have a bi-directional relationship Person can see Municipality (Through Address class) and Municipality can see Person (Through List of Person)

Now let's see The following scenario

Person person = new Person();
Municipality municipality = new Municipality();

Address address = new Address();
address.setMunicipality(person);

person.setAddress(address);

session.save(person);

You will see

INSERT INTO PERSON blah, blah, blah...

Because of @Cascade(SAVE_UPDATE)

INSERT INTO MUNICIPALITY blah, blah, blah...

But because of The bi-directional relationship, You should set up which property is The owner of The relationship. Owner of The relationship ? What is that ?

Suppose

public class A {

    @ManyToOne
    private B b;

}

And

public class B {

    @OneToMany
    @JoinColumn(name="B_ID")
    @Cascade(SAVE_UPDATE)
    private List<A> aList;

}

And you do

/*
 * a.getB() is null, right ?
A a = new A();

B b = new B();
b.getAList().add(a);

SQL outputs

/* Let's suppose B_ID generated value is 5
INSERT INTO B 

/*
 * because of @Cascade(SAVE_UPDATE)
INSERT INTO A (B_ID) VALUES(5)

But because a.getB() is null

You will also see

UPDATE A SET B_ID = null

It explains why you should use mappedBy attribute when using a bi-directional relationship.

Arthur Ronald F D Garcia
Hi! mmm... @transient is not what i want. I edit my post so i hope to explain the situation better. I know you can help me!!
blow
now I hope everything is clearer
blow
Thank you now I think I have understand! You have been very clear.
blow
+1  A: 

Finally i think to find a solution... i do this:

@Entity
public class Municipality implements Serializable {

@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
private String country;
private String province;
private String name;
@OneToMany(mappedBy="address.municipality")
private List<Person> persons;

public Municipality() {
}

...

I have not changed other classes.

Is this correct or work only by chance?

Thanks.

blow
@blow It seems right! But According to The answer provided by yourself. You have a **bi-directional** relationship between Person and Municipality (Through @Embeddable Address), which **needs** mappedBy attribute. Notice when using a bi-directional relationship, **It is a good idea to use add convenience method to set up both sides**. Keep this in mind
Arthur Ronald F D Garcia
Ok! thank for advice!
blow