Most likely because you have a null column in the database mapped to a non-nullable property. NHibernate detects that the current value is different than the loaded value (null) and tries to save the entity.
On May 16, 6:02 pm, Julio Henriquez <[email protected]> wrote: > I'm still stuck in this error. So, today I activated the "Show SQL" > property in the configuration, > and to my surprise I find discover that when I try delete this entity > NHibernate actually does > an update witch results in the error because my DataTime property has > an invalid value. > > The question is why is NHibernate trying to update the entity before > the delete operation? > Here is my code: > > using (ITransaction tnx = > presentationSession.BeginTransaction()) { > try { > presentationSession.Delete(View.SelectedData); // > View.SelectedData has the reference I want to delete. > tnx.Commit(); > } catch { > tnx.Rollback(); > throw; > } > } > > This is my mapping: > > <?xml version="1.0" encoding="utf-8" ?> > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default- > lazy="false"> > <class > name="PTFS.Personal.Model.Empleado, PTFS.Personal" > table="Supervisores" > > > <id > name="Id" > unsaved-value="0" > access="field.camelcase" > > > <generator class="native" /> > </id> > <property name="Nombre" /> > <property name="Supervisor" /> > <property name="Cedula" /> > <property name="Cargo" /> > <property name="Localidad" /> > <property name="Traslado" column="DES_TRASLADO" /> > <property name="Cambio" column="DES_CAMBIO" /> > <property name="FechaTraslado" column="F_TRASLADO" /> > <property name="FechaCambio" column="F_CAMBIO" /> > <property name="Ingreso" column="F_INGRESO" /> > <property name="Egreso" column="F_EGRESO" /> > <property name="Sueldo" column="SUELDO_BRUTO" /> > </class> > </hibernate-mapping> > > And this is the output I get when I commit the changes with the above > code: > > NHibernate: UPDATE Supervisores SET Nombre = @p0, Supervisor = @p1, > Cedula = @p2, Cargo = @p3, Localidad = @p4, DES_TRASLADO = @p5, > DES_CAMBIO = @p6, F_TRASLADO = @p7, F_CAMBIO = @p8, F_INGRESO = @p9, > F_EGRESO = @p10, SUELDO_BRUTO = @p11 WHERE Id = @p12;@p0 = NULL, @p1 = > NULL, @p2 = NULL, @p3 = NULL, @p4 = NULL, @p5 = NULL, @p6 = NULL, @p7 > = NULL, @p8 = NULL, @p9 = 05/09/2005 12:00:00 a.m., @p10 = NULL, @p11 > = 0, @p12 = 3547 > > NHibernate: UPDATE Supervisores SET Nombre = @p0, Supervisor = @p1, > Cedula = @p2, Cargo = @p3, Localidad = @p4, DES_TRASLADO = @p5, > DES_CAMBIO = @p6, F_TRASLADO = @p7, F_CAMBIO = @p8, F_INGRESO = @p9, > F_EGRESO = @p10, SUELDO_BRUTO = @p11 WHERE Id = @p12;@p0 = NULL, @p1 = > NULL, @p2 = NULL, @p3 = NULL, @p4 = NULL, @p5 = NULL, @p6 = NULL, @p7 > = NULL, @p8 = NULL, @p9 = 01/01/0001 12:00:00 a.m., @p10 = NULL, @p11 > = 0, @p12 = 4628 > > It is first updating two different entities... and none of then are > the ones I want to delete, the Id of the entity I provide for deleting > is: 4601 > > Please, any help with this will be greatly appreciated. > > On May 6, 1:35 pm, Julio Henriquez <[email protected]> > wrote: > > > > > > > > > Hello, > > > I am familiar with the nature of aSqlDateTimeoverflowexception. > > But I just came a cross a situation very peculiar. The exception is > > thrown when I try to delete an entity not when I try to save it. If > > there is any information you could provide as to why this happing will > > be appreciated. > > > Thx, -- 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.
