Although you could try to use natural-id ( caching consequence) I
think unique-key is the one you are looking for see
http://www.benday.com/2006/04/02/howto-create-a-unique-constraint-using-nhibernate/
for more info

On 29 mei, 22:45, Ricardo Peres <[email protected]> wrote:
> natural-id is used for creating unique indexes over one or multiple
> columns:  http://ayende.com/blog/4061/nhibernate-natural-id.
>
> RP
>
>
>
>
>
>
>
> On Tuesday, May 29, 2012 5:02:22 PM UTC+1, sbohlen wrote:
>
> > Sorry, that's <database-object>, of course (was working on an issue re:
> > scoping elsewhere when I saw your post come through and so I apparently had
> > 'scope -on-the-brain' when typing my reply :)
>
> > -Steve B.
>
> > On Tuesday, May 29, 2012 12:01:13 PM UTC-4, sbohlen wrote:
>
> >> You want the <database-scope> mapping element; see
> >>http://ayende.com/blog/3947/nhibernate-mapping-database-objectfor an
> >> example of this in action.
>
> >> Cheers,
> >> -Steve B.
>
> >> On Tuesday, May 29, 2012 11:35:43 AM UTC-4, nerdia wrote:
>
> >>> Hi,
>
> >>> I was wondering if anyone could help me figure out how to setup a
> >>> constraint from the hibernate XML.
>
> >>> I need the combination of two columns to be unique.
>
> >>> So for instance, if the columns are Name and Type, Then you could have
> >>> the following combinations in the DB:
>
> >>> Name Type
> >>> John   Leader
> >>> John   Follower
> >>> Sam   Leader
>
> >>> I can add this to the DB directly with constraints:
> >>> ALTER TABLE [Members] ADD  CONSTRAINT [UQ_NameType] UNIQUE
> >>> NONCLUSTERED
> >>> (
> >>>         [Name],[Type] ASC
> >>> )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY
> >>> = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [MAIN]
>
> >>> But am not clear how to set it up in the XML.
>
> >>> Any help would be appreciated.
>
> >>> Thanks,
>
> >>> Nadia

-- 
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.

Reply via email to