Hi,
I have a many-to-many relationship between two classes: Tournament and Players
I set Cascade.SaveUpdate in the mappings, but when saving a Tournament instance, the Players will not be saved to the Players table. Nhibernate only writes parent and child key columns in the linking table. The DB is SQLite.
These are the mappings
public TournamentMap()
{
WithTable("Tournaments");
Id(x => x.Name);
Map(x => x.Start).Access.AsLowerCaseField();
Map(x => x.End).Access.AsLowerCaseField();
HasManyToMany<Player>(x => x.Players)
.WithTableName("TournamentsPlayers")
.WithParentKeyColumn("tournamentName")
.WithChildKeyColumn("playerName").AsSet()
.Access.AsLowerCaseField()
.Cascade.SaveUpdate().LazyLoad();
References(x => x.Type).Access.AsLowerCaseField()
.TheColumnNameIs("typeName")
.Cascade.SaveUpdate();
}
public class PlayerMap : ClassMap<Player>
{
public PlayerMap()
{
WithTable("Players");
Id(x => x.Name);
HasManyToMany<Player>(x => x.Tournaments)
.Access.AsLowerCaseField()
.WithTableName("TournamentsPlayers")
.WithParentKeyColumn("playerName")
.WithChildKeyColumn("tournamentName").AsSet()
.Cascade.SaveUpdate().IsInverse().LazyLoad();
}
}