Is there any way you could add a primary key to the mapping table? I tried using composite keys before and had issues. The ActiveRecord documentation discourages their use due to the complexities:
http://stw.castleproject.org/Active%20Record.Primary%20Key%20Mapping.ashx Once I added a primary key to my mapping table, the HasAndBelongsToMany stuff was much easier to manage (from what I remember). --- Patrick Steele http://weblogs.asp.net/psteele On Tue, Nov 30, 2010 at 8:12 AM, Adriano Ribeiro <[email protected]> wrote: > Hi, > > I would like ask your help, i have follow cenary: > > database tables > > Users > id <- table key > name > > Menus > id <- table key > text > > MenuUser > user_id <- composite > menu_id table key with user_id and menu_id > strTipAcess > > ActiveRecord map > > [ActiveRecord("Users", DynamicUpdate = true, Lazy = true)] > public class User > { > [PrimaryKey(PrimaryKeyType.Native)] > public virtual Int32 Id { get; set; } > > [Property] > public virtual String Name { get; set; } > > [HasAndBelongsToMany(typeof(MenuUser), > Table = "MenuUser", CompositeKeyColumnRefs = new String[] > { "user_id", "menu_id" }, > ColumnKey = "user_id", Lazy = true, Inverse = true, > Cascade = ManyRelationCascadeEnum.SaveUpdate)] > public virtual IList<MenuUser> Access { get; set; } > } > > > [ActiveRecord("MenuUser", DynamicUpdate = true, Lazy = true)] > public class MenuUser > { > [CompositeKey] > public virtual MenuUserKey Key { get; set; } > > [Property] > public virtual Char strTipAcess { get; set; } > } > > [Serializable] > public class MenuUserKey > { > [KeyProperty] > public virtual Int32 user_id{ get; set; } > > [KeyProperty] > public virtual Int32 menu_id{ get; set; } > } > > Error i get when i try use User.Access: > > NHibernate.MappingException: Repeated column in mapping for > collection: User.Access column: user_id > > I saw some exemples com ActiveRecord tests, and Monorails > documentations, but, any of this case are like this, because the > relationship table didn´t have attributes. > > > Any help is very appreciated, thanks guys. > > -- > You received this message because you are subscribed to the Google Groups > "Castle Project Users" 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/castle-project-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Castle Project Users" 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/castle-project-users?hl=en.
