-->
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: problem with AttributeMapper and CompositeId
PostPosted: Thu Dec 01, 2011 10:57 am 
Newbie

Joined: Thu Dec 01, 2011 10:47 am
Posts: 4
I got stuck trying to implement CompositeId.
I'm using the NHibernate AttributeMapper.

my data structure:
1) User-Table with id and several other fields
2) UserSetting Table where the UserId, a setting name and a value are stored. the userName and the setting should be the key together. also the UserId should be mapped to a User-Instance.

heres the code:

User:
Code:
[NHibernate.Mapping.Attributes.Class(Table="_tblBenutzer")]
public class User
{
        [NHibernate.Mapping.Attributes.Id(0,Column="id",TypeType=typeof(int),UnsavedValue="0")]
        [NHibernate.Mapping.Attributes.Generator(1, Class = "native")]
        [NHibernate.Mapping.Attributes.CompositeElement(3,ClassType = typeof(User))]
        public virtual int Id { get { return _id; } set { _id = value; } }

        [NHibernate.Mapping.Attributes.Property(Column = "benutzername", NotNull = false, TypeType = typeof(string), Length = 50)]
        public virtual string Benutzername { get { return _username; } set { _username = value; } }
..... and so on..


UserSetting:
Code:
[NHibernate.Mapping.Attributes.Class(Table = "tblBenutzerKonfiguration")]
    public class UserSetting
    {
        [NHibernate.Mapping.Attributes.CompositeId(0)]
        [NHibernate.Mapping.Attributes.KeyProperty(1, Name = "Name", Column = "name", TypeType=typeof(string))]
        [NHibernate.Mapping.Attributes.KeyManyToOne(2, Name = "User", Column = "benutzerId", ClassType=typeof(User))]
        public virtual User User { get { return _user; } set { _user = value; } }

        public virtual string Name { get { return _name; } set { _name = value; } }

        [NHibernate.Mapping.Attributes.Property(0, Column = "wert", NotNull = false, TypeType = typeof(string), Length = 1000)]
        public virtual string Value { get { return _value; } set { _value = value; } }
  ....


thats it.. but when i try to run my project i get an error at:
Code:
config.AddInputStream(NHibernate.Mapping.Attributes.HbmSerializer.Default.Serialize(
                System.Reflection.Assembly.GetExecutingAssembly()));

saying: "Could not compile deserialized mapping document."

what am i doing wrong?


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.