How to make many to many relationships in hibernate same table Example
I have a model name Product i want to add more Products
want to create extra table where there will two Fields producid and product2 M-to-Many
public class Product
{
public virtual int Id { get; set; }
public virtual IList<Product> ManyProduct { get; set; }
}
Mapping
public class ProductMap : ClassMap<Product>
{
public ProductMap()
{
Id(x => x.Id);
Map(x => x.ImageUrl);
HasManyToMany(x => x.ManyProduct)
.Cascade.All()
.Table("ProductInProduct");
}
}