Cascada al simular muchos a muchos

I have a requirement to store many-to-many relation in the object model (that is because I have some fields in the many-to-many table)

So, I have two objects: A and C. And third object B that has links to A and C. (So it has foreign fields to A and C) So B has one A and one C. A has many B's, C has many B's

I want to be able to create new A() and save it to the database, without directly saving B and C. But I want to cascade to do it for me. I added Cascade.All() to all foreign fields that I have, but I receive foreign key error (it saves A, and than tries to save B after it, - but it should save C before)

What can I do to achive this?

P.S. I do not attach any code example, as it would be big. Hope that I can receive help without it, but if that won't help - I'll attach it

preguntado el 08 de noviembre de 11 a las 16:11

1 Respuestas

The problem was I had set Id of one of the objects by myself (that was an old code, that I forgot to ged rid off) and NHibernate didn't give a proper exception message.

So, problem solved, tnx

respondido 09 nov., 11:14

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.