Buenas,
Tengo un problema
tengo un maestro y un detalle , trato de guardar en el maestro y sus
detalles(Lineas) y me aparece en siguiente mensaje:
Exception: a different object with the same identifier value was
already associated with the session.
Para esto estoy usando Conform. y NH 3, anteriormente habia hecho algo
similar con mapping en xml, quizas este faltando algo en el mapping by
code de conform.
Aqui las entidades y el mapping
Maestro->
mapper.Class<Medication>(cm =>
{
cm.Id(o => o.Id, im =>
im.Generator(Generators.Assigned));
cm.ManyToOne(
x => x.Patient,
m =>
{
m.Column("IdPatient");
m.Fetch(FetchMode.Join);
m.NotNullable(true);
});
cm.ManyToOne(
x => x.Service,
m =>
{
m.Column("IdService");
m.Fetch(FetchMode.Join);
m.NotNullable(true);
});
cm.Bag(
o => o.Sessions,
x =>
{
x.Key(k => k.Column("Id"));
x.Cascade(Cascade.All);
x.Table("Session");
},
x =>
{
x.ManyToMany(k => k.Column("Id"));
x.ManyToMany(g =>
g.Class(typeof(Session)));
});
});
Detalle->
mapper.Class<Session>(cm =>
{
cm.Id(o => o.Id, im =>
im.Generator(Generators.Assigned));
cm.ManyToOne(
x => x.Medication,
m =>
{
m.Column("IdMedication");
m.Fetch(FetchMode.Join);
m.Cascade(Cascade.Persist | Cascade.Remove);
});
});
Espero me puedan dar luces.
Gracias
--
Para escribir al Grupo, hágalo a esta dirección:
[email protected]
Para más, visite: http://groups.google.com/group/NHibernate-Hispano