How do I migrate a ManyToOne to a ManyToMany relationship in Hibernate?

Posted by spderosso on Stack Overflow See other posts from Stack Overflow or by spderosso
Published on 2010-03-25T21:13:56Z Indexed on 2010/03/25 21:43 UTC
Read the original article Hit count: 350

Filed under:
|
|

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!

© Stack Overflow or respective owner

Related posts about java

Related posts about hibernate