These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Two Column Table with CompositeID?? HOW??
PostPosted: Tue Aug 28, 2007 8:38 am 
Newbie

Joined: Tue Aug 28, 2007 8:22 am
Posts: 2
i have a simple table:

document_id
user_name

I want to create a class that has attribute mappings. This table does not have a unique ID field. The UNIQUE Constraint is document__id and user_name together. Can someone please help me with this attributes mapping? Thank you very much in advance. Here is what I have. It does not work...

namespace InboundModel
{
[NHibernate.Mapping.Attributes.Class(Table = "USER_IGNORED_DOCS")]
public class UserIgnoredDocs
{
private int _inboundDocsId;
private string _inboundUserName;

/// <summary> Gets/Sets InboundDocsID. </summary>
[NHibernate.Mapping.Attributes.CompositeId(1)]
[NHibernate.Mapping.Attributes.KeyProperty(2, Name = "InboundDocsId", Column = "INBOUND_DOCS_ID")]
[NHibernate.Mapping.Attributes.KeyProperty(3, Name = "InboundUserName", Column = "USER_IGNORED_DOCS", Access = "property")]
public virtual int InboundDocsId
{
get { return _inboundDocsId; }
set { _inboundDocsId = value; }
}

/// <summary> Inbound User Name. </summary>
[NHibernate.Mapping.Attributes.Property(NotNull = false, Column = "INBOUND_USER_NAME")]
public virtual string InboundUserName
{
get { return _inboundUserName; }
set { _inboundUserName = value; }
}

}
}

the exception I get is:

NHibernate.MappingException: Could not compile the mapping document:(unknown) --> NHibernate.MappingException: composite-id class must override Equals();


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.