Eso de hacer el delete de la propia entidad ya tiene más sentido :). 
No obstante, como yo también soy un principiante, me gustaría que 
alguien que estuviese más ducho me dijera si es necesario.

En cuanto a lo del inverse=true, es necesario? Lo digo porque yo no 
necesito tener ninguna referencia desde EmailDA a DatosPersonalesDA, y 
según tengo entendido, inverse=true, es que puedes dar la vuelta, es 
decir:

 Persona 1 - n Direcciones

 Persona.Direcciones[0].Persona

On 30 ene, 19:29, "Guillermo Ruffino" <[EMAIL PROTECTED]> wrote:
> Segun lo poco que entiendo de esto, tu EmailDA es una entidad, y por lo
> tanto hay que llamar al Delete en la entidad, el update en datosPersonales
> solo va a querer actualizar la relación, para ello haciendo el update que es
> el que falla.
> Yo intentaría hacer delete a la entidad (EmailDA) y poner inverse=true en el
> bag, para que no haga el update, pero en realidad no se, alguien de paso nos
> explica?
>
> -----Original Message-----
> From: [email protected]
>
> [mailto:[EMAIL PROTECTED] On Behalf Of Chili
> Sent: Tuesday, January 30, 2007 15:13
> To: NHibernate-Hispano
> Subject: [NHibernate-Hispano] Re: Problemas con un update
>
> Ya he probado con eso, quedándome el mapping de DatosPersonalesDA así:
>
> <?xml version="1.0" encoding="utf-8" ?>
> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" default-
> lazy="false">
>   <class
> name="dataAccess.csfiles.datospersonalesygrupo.DatosPersonalesDA,
> dataAccess" table="datospersonales">
>     <id name="IdPersonales" column="idpersonales">
>       <generator class="assigned" />
>     </id>
>     <bag name="Emails" cascade="all-delete-orphan">
>       <key column="idpersonales"/>
>       <one-to-many
> class="dataAccess.csfiles.datospersonalesygrupo.EmailDA, dataAccess"/>
>     </bag>
>   </class>
> </hibernate-mapping>
>
> y el error sigue siendo exactamente el mismo. Alguna otra sugerencia?
>
> On 30 ene, 18:11, "Dario Quintana" <[EMAIL PROTECTED]>
> wrote:
> > La columna idPersonales dentro de la clase EmailDA no está permitiendo
> > valores null. NH está haciendo un Update insertando null en
> > idPersonales.
>
> > Pobrá con cascade="all-delete-orphan" a ver q pasa.
>
> > Saludos
>
> > On 1/30/07, Chili <[EMAIL PROTECTED]> wrote:
>
> > > Bien, mis clases son éstas:
>
> > > public class DatosPersonalesDA
> > >     {
> > >         private int idPersonales;
> > >         private string name, surname, place, urlPhoto, urlPage;
> > >         private DateTime date;
> > >         private IList<EmailDA> emails;
> > >         private IList<TelephoneDA> telephones;
> > >         private IList<PostalDA> postals;
> > >         private IList<IdentsDA> idents;
>
> > >         // Aquí irían todas las propiedades de cada atributo
> > > }
>
> > > public class EmailDA
> > >     {
> > >         private int idPersonales;
> > >         private string email;
>
> > >         // Propiedades
> > > }
>
> > > Ahora los mapping de cada clase:
>
> > > <?xml version="1.0" encoding="utf-8" ?>
> > > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" default-
> > > lazy="false">
> > >   <class
> > > name="dataAccess.csfiles.datospersonalesygrupo.DatosPersonalesDA,
> > > dataAccess" table="datospersonales">
> > >     <id name="IdPersonales" column="idpersonales">
> > >       <generator class="assigned" />
> > >     </id>
> > >     <bag name="Emails" cascade="all">
> > >       <key column="idpersonales"/>
> > >       <one-to-many
> > > class="dataAccess.csfiles.datospersonalesygrupo.EmailDA, dataAccess"/>
> > >     </bag>
> > >   </class>
> > > </hibernate-mapping>
>
> > > Omito el mapeo del resto de atributos.
>
> > > <?xml version="1.0" encoding="utf-8" ?>
> > > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" default-
> > > lazy="false">
> > >   <class name="dataAccess.csfiles.datospersonalesygrupo.EmailDA,
> > > dataAccess" table="email" dynamic-update="true">
> > >     <composite-id>
> > >       <key-property name="IdPersonales" column="idpersonales"/>
> > >       <key-property name="Email" column="mail"/>
> > >     </composite-id>
> > >   </class>
> > > </hibernate-mapping>
>
> > > Ahora bien, el problema es que al borrar un email, y luego actualizar,
> > > me da error. Actualizo un member, que se relaciona con las clases
> > > anteriores de la siguiente manera: un member tiene un curriculum, un
> > > curriculum tiene unos datos personales, y los datos personales
> > > contienen una colección de Emails.
>
> > >     public class MemberDA
> > >     {
> > >         private string loginName, name, degree, category, laboralUnit,
> > > company;
> > >         private CurriculumDA curriculum;
> > >         private IList<DatosGrupoInvestigacionDA> gruposInvestigacion;
> > >         private RolDA rol;
> > > }
>
> > >     public class CurriculumDA
> > >     {
> > >         private int idCurriculum;
> > >         private string version, format;
> > >         private DateTime date;
> > >         private DatosPersonalesDA datosPersonales;
> > >         private IList<ItemsJobDescriptionDA> trabajos;
> > > }
>
> > > El fragmento de código donde salta la excepción es el siguiente:
>
> > >         public void saveMember(MemberDA member) {
> > >             if (!session.IsConnected)
> > >                 session.Reconnect();
> > >             ITransaction transaction = null;
> > >             try
> > >             {
> > >                 transaction = session.BeginTransaction();
> > >                 session.Update(member);
> > >                 transaction.Commit();
> > >                 session.Disconnect();
> > >             }
> > >             catch (Exception e)
> > >             {
> > >                 transaction.Rollback();
> > >                 session.Disconnect();
> > >                 throw e;
> > >             }
> > >         }
>
> > > Más concretamente, en el transaction.Commit();
>
> > > El mensaje de la excepción es:
>
> > > Cannot insert the value NULL into column 'idpersonales', table
> > > 'curriculum.dbo.email'; column does not allow nulls. UPDATE fails.
> > > The statement has been terminated.
>
> > >  Exception Details: System.Data.SqlClient.SqlException: Cannot insert
> > > the value NULL into column 'idpersonales', table
> > > 'curriculum.dbo.email'; column does not allow nulls. UPDATE fails.
>
> > > Stack Trace:
>
> > > [SqlException (0x80131904): Cannot insert the value NULL into column
> > > 'idpersonales', table 'curriculum.dbo.email'; column does not allow
> > > nulls. UPDATE fails.
> > > The statement has been terminated.]
> > >    System.Data.SqlClient.SqlConnection.OnError(SqlException exception,
> > > Boolean breakConnection) +177
> > >    System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
> > > exception, Boolean breakConnection) +68
>
> > > System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserState
> > > Object stateObj) +199
> > >    System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior,
> > > SqlCommand cmdHandler, SqlDataReader dataStream,
> > > BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
> > > stateObj) +2300
> > >    System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader
> > > ds, RunBehavior runBehavior, String resetOptionsString) +147
>
> > > System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior
> > > cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean
> > > async) +1021
> > >    System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
> > > cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
> > > method, DbAsyncResult result) +314
>
> > > System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult
> > > result, String methodName, Boolean sendToPipe) +413
> > >    System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +115
> > >    NHibernate.Impl.BatcherImpl.ExecuteNonQuery(IDbCommand cmd) in c:
> > > \net\nhibernate-1.2.0.Beta1\nhibernate\src\NHibernate\Impl
> > > \BatcherImpl.cs:172
>
> > > NHibernate.Persister.Collection.AbstractCollectionPersister.DeleteRows(
> > > IPersistentCollection collection, Object id, ISessionImplementor
> > > session) in c:\net\nhibernate-1.2.0.Beta1\nhibernate\src\NHibernate
> > > \Persister\Collection\AbstractCollectionPersister.cs:947
>
> > > [ADOException: could not delete collection rows:
> > > [dataAccess.csfiles.datospersonalesygrupo.DatosPersonalesDA.Emails#1]]
> > >    dataAccess.csfiles.DBManager.saveMember(MemberDA member) in C:
> > > \Documents and Settings\César Díaz García\Mis documentos\Visual Studio
> > > 2005\Projects\dataAccess\dataAccess\DBManager.cs:97
> > >    Controlador.saveMember(MemberDA member) in c:\Documents and Settings
> > > \César Díaz García\Mis documentos\Visual Studio 2005\WebSites\proyecto
> > > \App_Code\Controlador.cs:58
> > >    web_privado_perfil_modificar.ButtonGuardar_Click(Object sender,
> > > EventArgs e) in c:\Documents and Settings\César Díaz García\Mis
> > > documentos\Visual Studio 2005\WebSites\proyecto\web\privado
> > > \perfil_modificar.aspx.cs:51
> > >    System.Web.UI.WebControls.Button.OnClick(EventArgs e) +75
> > >    System.Web.UI.WebControls.Button.RaisePostBackEvent(String
> > > eventArgument) +97
>
> > > System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.Ra
> > > isePostBackEvent(String eventArgument) +7
> > >    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
> > > sourceControl, String eventArgument) +11
> > >    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
> > > +33
> > >    System.Web.UI.Page.ProcessRequestMain(Boolean
> > > includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
> > > +4880
>
> > > The statement has been terminated.--
> > Dario Quintanahttp://blog.darioquintana.com.ar


--~--~---------~--~----~------------~-------~--~----~
Para escribir al Grupo, hágalo a esta dirección: 
[email protected]
Para más, visite: http://groups-beta.google.com/group/NHibernate-Hispano
-~----------~----~----~----~------~----~------~--~---

Responder a