Well your exception says: NHibernate.MappingException: composite-id class
must override Equals
(): Competency.Domain.AccessibleDocumentsDto

On Sat, Mar 28, 2009 at 1:19 PM, nobodybutca <[email protected]> wrote:

>
> James Gregory,
>
> Nope? that's all of my codes above.
>
>
> On Mar 28, 8:11 pm, James Gregory <[email protected]> wrote:
> > nobodybutca: Have you overridden Equals in your entity?
> >
> > On Sat, Mar 28, 2009 at 11:29 AM, nobodybutca <[email protected]>
> wrote:
> >
> > > Mine is here:
> >
> > > Error is :
> > > NHibernate.MappingException: composite-id class must override Equals
> > > (): Competency.Domain.AccessibleDocumentsDto
> > > NHibernate.MappingException: Could not compile the mapping document:
> > > (XmlDocument)
> >
> > > public class AccessibleDocumentsDto
> > >    {
> > >        public virtual int RoleId { get; set; }
> > >        public virtual int DocId { get; set; }
> > >        public virtual bool WithAccess { get; set; }
> > >    }
> >
> > >  public class AccessibleDocumentsDtoMap :
> > > ClassMap<AccessibleDocumentsDto>
> > >    {
> > >        public AccessibleDocumentsDtoMap()
> > >        {
> > >            WithTable("dbo.RoleDocument");
> > >            UseCompositeId()
> > >                .WithKeyProperty(x => x.RoleId, "RoleID")
> > >                .WithKeyProperty(x => x.DocId, "DocID");
> > >            Map(x => x.WithAccess)
> > >                .FormulaIs("case when AllowFullAccess = 1 or AllowEdit
> > > = 1 or AllowRead = 1 or AllowView = 1 then 1 else 0 end");
> > >        }
> > >    }
> >
> > > XMB File:
> > > <?xml version="1.0" encoding="utf-8" ?>
> > > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
> > >  <class name="Entities.RoleDocument, Entities"
> > > table="dbo.RoleDocument">
> > >    <composite-id name="Id" class="Entities">
> > >                  <key-property name="DocID" column="DocID"
> > > type="System.Int32"/>
> > >                  <key-property name="RoleID" column="RoleID"
> > > type="System.Int32"/>
> > >    </composite-id>
> > >                <property name="AllowEdit" column="AllowEdit"
> > > type="System.Boolean"
> > > not-null="true"/>
> > >                <property name="AllowFullAccess"
> column="AllowFullAccess"
> > > type="System.Boolean" not-null="true"/>
> > >                <property name="AllowRead" column="AllowRead"
> > > type="System.Boolean"
> > > not-null="true"/>
> > >                <property name="AllowView" column="AllowView"
> > > type="System.Boolean"
> > > not-null="true"/>
> > >  </class>
> > > </hibernate-mapping>
> >
> > > SCHEMA:
> > > CREATE TABLE [dbo].[RoleDocument](
> > >        [RoleID] [int] NOT NULL,
> > >        [DocID] [int] NOT NULL,
> > >        [AllowFullAccess] [bit] NOT NULL CONSTRAINT
> > > [DF_RoleDocument_AllowFullAccess]  DEFAULT (0),
> > >        [AllowEdit] [bit] NOT NULL CONSTRAINT
> [DF_RoleDocument_AllowEdit]
> > > DEFAULT (0),
> > >        [AllowRead] [bit] NOT NULL CONSTRAINT
> [DF_RoleDocument_AllowRead]
> > > DEFAULT (0),
> > >        [AllowView] [bit] NOT NULL CONSTRAINT
> [DF_RoleDocument_AllowView]
> > > DEFAULT (0),
> > >  CONSTRAINT [PK_RoleDocument] PRIMARY KEY CLUSTERED
> > > (
> > >        [RoleID] ASC,
> > >        [DocID] ASC
> > > )WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF, FILLFACTOR = 90) ON
> > > [PRIMARY]
> > > ) ON [PRIMARY]
> >
> > > But if I use this Map:
> >
> > >    public class AccessibleDocumentsDtoMap :
> > > ClassMap<AccessibleDocumentsDto>
> > >    {
> > >        public AccessibleDocumentsDtoMap()
> > >        {
> > >            WithTable("dbo.RoleDocument");
> > >               Id(x => x.RoleId)
> > >                    .TheColumnNameIs("RoleID")
> > >                    .GeneratedBy.Assigned();
> > >               Map(x => x.DocId)
> > >                    .ColumnName("DocID")
> > >                    .Not.Nullable();
> > >            Map(x => x.WithAccess)
> > >                /.FormulaIs("case when AllowFullAccess = 1 or
> > > AllowEdit = 1 or AllowRead = 1 or AllowView = 1 then 1 else 0 end");
> > >        }
> > >    }
> >
> > > All returned results are all duplicates, If we say it returns 100
> > > records, all that 100 are identical. =(
> >
> > > I was suppose to ask you on twitter, if there are writing about
> > > "UseCompositeId()" =)
> >
> > > On Mar 28, 2:34 am, Matt <[email protected]> wrote:
> > > > So we are working on a Legacy Database that has some interesting
> table
> > > > setups.
> >
> > > > What we have is a class that contains a state and county.  Which we
> > > > have mapped like so:
> >
> > > > UseCompositeID().WithKeyProperty(x => x.ID, "XXXXXX").WithKeyProperty
> > > > (x => x.ID, "YYYYYY");
> >
> > > > So now the issue comes when we go to map to that Reference.
> >
> > > > The table we are mapping from has different column names to begin
> > > > with, and the bridge table has FK on both the keys, where the table
> we
> > > > are referencing from does not.
> >
> > > > I've tried many of the Reference ideas such as "WithColumnNames" but
> > > > that throws an error and does not build.  If anyone could provide a
> > > > little insight on what we may do to be able to fix this issue, it
> > > > would be much appreciated.
> >
>

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

Reply via email to