Es verdad Jose, además de que si no me equivoco el uso de SaveOrUpdate() debería ser en casos muy puntuales:
http://docs.jboss.org/hibernate/core/3.3/reference/en/html/objectstate.html *The usage and semantics of saveOrUpdate() seems to be confusing for new users. Firstly, so long as you are not trying to use instances from one session in another new session, you should not need to useupdate(), saveOrUpdate(), or merge(). Some whole applications will never use either of these methods.* *Usually update() or saveOrUpdate() are used in the following scenario:* *the application loads an object in the first session* *the object is passed up to the UI tier* *some modifications are made to the object* *the object is passed back down to the business logic tier* *the application persists these modifications by calling update() in a second session* Saludos, <http://docs.jboss.org/hibernate/core/3.3/reference/en/html/objectstate.html> El 7 de julio de 2011 16:59, Jose Selesan <[email protected]> escribió: > En el caso del ejemplo, creo que no hace falta el segundo SaveOrUpdate. > Esto debería funcionar: > > using (var tx = session.BeginTransaction()){ > User u = new User(); > u.FirstName = "Gustavo"; > u.LastName = "Garcia"; > session.Save(u); > > u.BirthDate = DateTime.Now.AddYears(age * -1); > tx.Commit(); > } > > 2011/7/7 Walter Poch <[email protected]> > >> using (var tx = session.BeginTransaction()){ >> User u = new User(); >> u.FirstName = "Gustavo"; >> u.LastName = "Garcia"; >> session.SaveOrUpdate(u); >> u.BirthDate = DateTime.Now.AddYears(age * -1); >> session.SaveOrUpdate(u); >> tx.Commit(); >> } >> > > -- > Para escribir al Grupo, hágalo a esta dirección: > [email protected] > Para más, visite: http://groups.google.com/group/NHibernate-Hispano > -- Saludos, Walter G. Poch Sr. .Net Developer -------------------------------------------- Cell: +54 (9 341) 3353273 [email protected] -- Para escribir al Grupo, hágalo a esta dirección: [email protected] Para más, visite: http://groups.google.com/group/NHibernate-Hispano
