How do I migrate a ManyToOne to a ManyToMany relationship in Hibernate?
- by spderosso
I have a instance field of a class X that is mapped using Hibernate as a Many to One relationship. E.g:
public class X{
...
@ManyToOne(optional=false)
private Y iField;
...
}
That is correctly working with a particular schema. I know want to change this instance field iField to a List and a Many to Many relationship.
public class X{
...
@ManyToMany(optional=false)
private List<Y> iField;
...
}
What steps should I follow? Do I have to change the schema? in which way?
In case you need more info let me know.
Thanks!