well if you return the rowcount it should wirk, but, as usual, Fabio gave U a cleaner and simpler solution !
Try with formula as Fabio suggested ! Gianluca On Thu, Jun 17, 2010 at 5:44 PM, Eddie <[email protected]> wrote: > This is my SP > CREATE PROCEDURE dbo.NHObjetos_Update > @codigo VARCHAR(5), > @descripcion VARCHAR(50) > AS > > > > UPDATE [NHObjetos] SET [descripcio...@descripcion, > modificado=GETDATE() > WHERE [codigo] = @codigo > > GO > > I should return the @@roxcount? using return? or select @@rowcount? > > > Can I use the <formula> as follow? > <property name="UpdateDate" type="DateTime" update="false" > formula="getdate" insert="false" generated="always" > > <column name="last_update_date" sql-type="datetime" not- > null="true" /> > </property> > > > > > On 17 jun, 12:34, Fabio Maulo <[email protected]> wrote: > > you can use a simple <formula> and generated=always > > > > > > > > > > > > On Thu, Jun 17, 2010 at 11:04 AM, Eddie <[email protected]> wrote: > > > Hi > > > I want to update an object using a stored procedure. The reason to do > > > this is to update a field 'last_update_date'. So in the sp I set > > > last_update_date = getdate() because a need to save the server time. > > > The problem is I am getting an error when using stored procedure. > > > Error: "Batch update returned unexpected row count from update; actual > > > row count: 0; expected: 1" > > > > > If I remove <sql-update > the record is updated but no the field > > > last_update_date. > > > How I can solve this error? > > > There is another way to update this kind of fields? > > > > > This is my mapping file: > > > hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" > > > assembly="HP.NHibernate.Framework" > > > namespace="HP.NHibernate.Framework.Domain"> > > > <class name="Objeto" catalog="Trabajos" schema="dbo" > > > table="NHObjetos" > > > > <id name="Codigo" type="String" unsaved-value=""> > > > <column name="codigo" sql-type="varchar" length="5" not- > > > null="true" unique="true"/> > > > <generator class="assigned" /> > > > </id> > > > <property name="Descripcion" type="String"> > > > <column name="descripcion" length="50" sql-type="varchar" not- > > > null="true" /> > > > </property> > > > > > <property name="UpdateDate" type="DateTime" update="false" > > > insert="false" generated="always" > > > > <column name="last_update_date" sql-type="datetime" not- > > > null="true" /> > > > </property> > > > > > <sql-update >exec Trabajos.dbo.NHObjetos_Update ?,? </sql-update> > > > </class> > > > </hibernate-mapping> > > > > > My code is: > > > public void UpdateObjeto() > > > { > > > using (RepositoryBase repo = new RepositoryBase()) > > > { > > > try > > > { > > > repo.BeginTransaction(); > > > Objeto objeto = (Objeto) > > > repo.GetById(typeof(Objeto), "DEF45"); > > > objeto.Descripcion = "pepepe"; > > > > > repo.Update(objeto); > > > > > repo.CommitTransaction(); > > > } > > > catch (Exception ex) > > > { > > > repo.RollbackTransaction(); > > > } > > > } > > > } > > > > > I will apreciate any tip. > > > Thanks. > > > > > -- > > > 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]<nhusers%[email protected]> > <nhusers%[email protected]<nhusers%[email protected]>> > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/nhusers?hl=en. > > > > -- > > Fabio Maulo > > -- > 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]<nhusers%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > > -- Gianluca Gravina http://blogs.ugidotnet.org/thinkingingrava -- 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.
