There's now a UniqueKey on the Discriminate method, try that. Binaries will take a few minutes to catch up.
On Thu, Aug 27, 2009 at 12:10 PM, Artur Dorochowicz < [email protected]> wrote: > > In XML it would like this: > > <?xml version="1.0" encoding="utf-8" ?> > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" > assembly="NHibernate.Test" > namespace="NHibernate.Test.NHSpecificTest.NH1234" > default-access="property" > auto-import="true" default- > cascade="none" default-lazy="false"> > <class xmlns="urn:nhibernate-mapping-2.2" discriminator-value="255" > name="ParentClass" table="Hierarchy"> > <id name="Id" type="Guid"> > <column name="Id" /> > <generator class="guid.comb" /> > </id> > <discriminator type="Byte" > > <column name="TypeDiscriminator" > unique-key="UQ_Type_Name" not- > null="true"/> > </discriminator> > <property name="Name" type="String"> > <column name="Name" unique-key="UQ_Type_Name"/> > </property> > <subclass name="DerivedClass" discriminator-value="0"> > <property name="ChildProperty" type="String"> > <column name="ChildProperty"/> > </property> > </subclass> > </class> > </hibernate-mapping> > > Please note discriminator element with column element specifying > unique-key. > > For this model: > > namespace NHibernate.Test.NHSpecificTest.NH1234 > { > public class ParentClass > { > public Guid Id { get; set; } > public string Name { get; set; } > } > > > public class DerivedClass : ParentClass > { > public string ChildProperty { get; set; } > } > } > > And it gives this schema: > > create table Hierarchy ( > Id UNIQUEIDENTIFIER not null, > TypeDiscriminator TINYINT not null, > Name NVARCHAR(255) null, > ChildProperty NVARCHAR(255) null, > primary key (Id), > unique (TypeDiscriminator, Name) > ) > > > Basically, I would like to have something unique within each type. > > > > On 27 Sie, 11:59, James Gregory <[email protected]> wrote: > > Where are you trying to specify this unique key? How would you do it with > > xml? > > > > UniqueKey("discriminatorcolumn,anothercolumn") > > > > On Wed, Aug 26, 2009 at 6:00 PM, Artur Dorochowicz < > > > > [email protected]> wrote: > > > > > Hello, > > > > > I have this requirement to include a discriminator column in a unique > > > key. From NH mapping schema, I see that that can be done. > > > > > I know that FNH does not support such construct in its fluent > > > interface, but I was wondering, maybe there is some extension point or > > > a way to add attribute or literal xml to specify that. I couldn't find > > > any so I'm asking here for help. > > > > > I'm using manual mappings, so it's not automapping related. > > > > > Thanks > > > > > Artur > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Fluent NHibernate" 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/fluent-nhibernate?hl=en -~----------~----~----~----~------~----~------~--~---
