Hi Fabio,
Here it is:
public EmployeeDto MakePersistant (EmployeeDto entity)
{
Employee e =
ProjectTracker.Domain.DomainConverter.Converter.EmployeeDtoToEntity
(entity);
using(UnitOfWork.Start()){
base.SaveOrUpdate(e);
//UnitOfWork.Current.TransactionalFlush();
UnitOfWork.CurrentSession.Flush();
}
entity.Id = e.Id;
entity.PersonDto.Id = e.Person.Id;
entity.PersonDto.AdressDto.Id = e.Person.Adress.Id;
return entity;
}
My repository<T> looks like:
public T SaveOrUpdate(T entity)
{
Session.SaveOrUpdate(entity);
return entity;
}
The UnitOfWork ist from:
http://hibernatingrhinos.googlecode.com/svn/trunk/UnitOfWork/
Peter
On 29 Jan., 14:16, Fabio Maulo <[email protected]> wrote:
> which is the impl. of employeeService.MakePersistant ? (or the impl of
> DAO/Repository if you are calling NH's session method there).
>
> 2010/1/29 Peter Forstmeier <[email protected]>
>
>
>
>
>
> > Hi List,
> > i have big problems with SaveOrUpdate();
> > Insertin new values aork as expected.
> > But, Updateing a value didn't work
> > My Mappings:
>
> > public class EmployeeMapping : BaseClassMap<Employee>
> > {
> > public EmployeeMapping()
> > {
> > References(x => x.Person).Not.Nullable().Not.LazyLoad
> > ().Cascade.SaveUpdate();
> > ......
> > }
>
> > public PersonMapping()
> > {
> > References(x => x.Adress).Not.Nullable().Cascade.SaveUpdate
> > ().Not.LazyLoad();
> > ------
> > }
>
> > public AdressMapping()
> > {
>
> > Map(x => x.AdressLine1);
> > ----
> > }
> > All Identities are GUID's
> > As i said, Insert work.
>
> > All SQL Statemenst fir insert are generated:
>
> > My TestCode:
>
> > [Test]
> > public void CanChangeAdress ()
> > {
> > List<EmployeeDto> initialList = employeeService.GetList();
> > EmployeeDto e1 = employeeService.Get(initialList[0].Id);
>
> > e1.HoursPerWeek = 40;
> > SQL generated
> > e1.PersonDto.Firstname = "testvalue"; NO SQL
> > generated
> > e1.PersonDto.AdressDto.AdressLine1 = "teststreet"; NO SQL
> > generated
>
> > employeeService.MakePersistant(e1);
>
> > this means, when i Update an Employee, only Properties belonging
> > directly to Employee are updated. The referenced classes like Person
> > and Adress aren't touched by Update
>
> > Any idea,
> > Thanks in advance
> > Peter
>
> > --
> > 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.
>
> --
> Fabio Maulo- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -
--
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.