-->
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: XSD --> Classes --> HBM question
PostPosted: Tue Feb 20, 2007 12:17 pm 
Newbie

Joined: Tue Feb 20, 2007 12:04 pm
Posts: 16
I really think what I'm trying to accomplish should be fairly easy, however I can't seem to find any good information that addresses how to solve this.

Basically, I'm trying to create NHibernate mapping for some simple classes that have been driven via XSD. For example, here's the simple class structure that I'm trying to map:

Code:
namespace com.test.schema {
    using System.Xml.Serialization;
   
   
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.42")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:com.test.schema")]
    [System.Xml.Serialization.XmlRootAttribute("User", Namespace="urn:com.test.schema", IsNullable=false)]
    public partial class UserType {
       
        private int userIdField;
       
        private string userNameField;
       
        private string nameField;
       
        private string emailField;
       
        private AliasType[] aliasField;
       
        /// <remarks/>
        public int UserId {
            get {
                return this.userIdField;
            }
            set {
                this.userIdField = value;
            }
        }
       
        /// <remarks/>
        public string UserName {
            get {
                return this.userNameField;
            }
            set {
                this.userNameField = value;
            }
        }
       
        /// <remarks/>
        public string Name {
            get {
                return this.nameField;
            }
            set {
                this.nameField = value;
            }
        }
       
        /// <remarks/>
        public string Email {
            get {
                return this.emailField;
            }
            set {
                this.emailField = value;
            }
        }
       
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute("Alias")]
        public AliasType[] Alias {
            get {
                return this.aliasField;
            }
            set {
                this.aliasField = value;
            }
        }
    }
   
    /// <remarks/>
    [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.42")]
    [System.SerializableAttribute()]
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:com.test.schema")]
    public partial class AliasType {
       
        private string typeField;
       
        private string firstField;
       
        private string middleField;
       
        private string lastField;
       
        /// <remarks/>
        public string Type {
            get {
                return this.typeField;
            }
            set {
                this.typeField = value;
            }
        }
       
        /// <remarks/>
        public string First {
            get {
                return this.firstField;
            }
            set {
                this.firstField = value;
            }
        }
       
        /// <remarks/>
        public string Middle {
            get {
                return this.middleField;
            }
            set {
                this.middleField = value;
            }
        }
       
        /// <remarks/>
        public string Last {
            get {
                return this.lastField;
            }
            set {
                this.lastField = value;
            }
        }
    }
}


As you can see, I have a simple one-to-many relationship between User and Alias. What is the best way to map these structures and what columns do I need in my database schema? I assume that I'll need additional "keys" to maintain the relationship.

Sorry if this is a basic question and I'm just missing something.


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.