Hi all.
I'm trying to manage collections. I get an error when I use the
annotation "[Transaction]" in my method.
The error is
"A collection with cascade="all-delete-orphan" was no longer
referenced by the owning entity instance: Cuenta"
My method
[CODE] [Transaction]
public void AgregarCuenta(int idPersona, string cuenta)
{
Persona persona = RepositoryPersona.Get(idPersona);
IList<Cuenta> cuentas = new List<Cuenta>();
Cuenta cta = new Cuenta();
cta.Numero = cuenta;
cta.Saldo = 100;
cta.Medico = persona;
cuentas.Add(cta);
persona.Cuentas.Clear();
persona.Cuentas = cuentas;
RepositoryPersona.Update(persona);
}[/CODE]
Parent Class
[HTML]<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="HP.Framework.Domain.Persona, HP.Framework"
table="Personas" lazy="false" >
<id name="ID" type="Int32" unsaved-value="0">
<column name="Id" sql-type="int" not-null="true" unique="true"
index="PK_Personas"/>
<generator class="native" />
</id>
<property name="Nombre" type="String">
<column name="nombre" length="50" sql-type="varchar" not-
null="true" />
</property>
<property name="Apellido" type="String">
<column name="apellido" length="50" sql-type="varchar" not-
null="true" />
</property>
<bag name="Cuentas" table="Cuentas" cascade="all-delete-orphan"
lazy="true" inverse="true">
<key column="id_profesional" />
<one-to-many class="HP.Framework.Domain.Cuenta, HP.Framework" />
</bag>
</class>
</hibernate-mapping>[/HTML]
Child Class
[HTML]<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="HP.Framework.Domain.Cuenta, HP.Framework"
table="Cuentas" lazy="false" >
<id name="ID" type="Int32" unsaved-value="0">
<column name="Id" sql-type="int" not-null="true" unique="true"/>
<generator class="native" />
</id>
<property name="Numero" type="String">
<column name="numero" length="50" sql-type="varchar" not-
null="true" />
</property>
<property name="Saldo" type="Decimal">
<column name="saldo" sql-type="numeric" not-null="true" />
</property>
<many-to-one name="Medico" column="id_profesional" not-null="true"
fetch="join" />
</class>
</hibernate-mapping>[/HTML]
If I don't use the transaction annotation everything work just fine.
But I need to use transactions for some scenarios.
Thanks for any help.
Eddie
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.