My table looks like this:
RoleId PK identitty
EmployeeId FK to EmployeeId on Employee table
Name
...
I am using the "identity generator" for the RoleId:
<id name="Id" type="System.Int64, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="RoleId" />
<generator class="identity" />
</id>
And same for EmployeeId in Employee mapping.
EmployeeId in Role mapping is mapped as many-to-one:
<many-to-one class="...." name="Employee">
<column name="EmployeeId" />
</many-to-one>
On 6 jan, 23:03, Fabio Maulo <[email protected]> wrote:
> which is the strategy you are using for Role-poid and Employee-poid ?
>
> 2010/1/6 HH <[email protected]>
>
>
>
>
>
> > I have a question regarding NHibernate in a web environment. The
> > question is basically the same as stated in the following
> > stackoverflow question:
>
> >http://stackoverflow.com/questions/822357/how-do-i-add-additional-cri...
>
> > In my case I have a one-to-many relation between Employee and Role. I
> > have mapped a Role collection on Employee and marked it as
> > inverse=”true”:
>
> > <bag name="Roles" cascade="all-delete-orphan" access="field.camelcase-
> > underscore" inverse="true">
> > <key column="EmployeeId"/>
> > <one-to-many class="Role" />
> > </bag>
>
> > The roles of an employee are editable in a browser application. The id
> > of the role is stored in a hidden field on the client and can
> > therefore be “hacked”. An employee is only supposed to update the name
> > of the role. And of course only roles which belong to the logged on
> > employee. However, when Nhibhernate updates a Role it only uses the Id
> > of the role in the where clause: Update Role Set Name = ‘ffff’ where
> > RoleId = 1.
> > Is it possible to instruct NHibernate to also use the EmployeeId when
> > updating the Role: Update Role Set Name = ‘ffff’ where RoleId = 1 and
> > EmployeeId = 2?
>
> > Same for the delete statement: Delete from Role where RoleId = 1 and
> > EmployeeId = 2.
>
> > What would be the best solution?
>
> > --
> > 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- Tekst uit oorspronkelijk bericht niet weergeven -
>
> - Tekst uit oorspronkelijk bericht weergeven -
--
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.