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: mapping question (lookup?)
PostPosted: Fri Jul 04, 2008 11:40 am 
Newbie

Joined: Tue Feb 20, 2007 12:04 pm
Posts: 16
Hibernate version: 1.2

Name and version of the database you are using: MSSQL 2005

I'm looking for some/advice direction regarding a mapping scenario and haven't been able to locate any leads on this yet. Here's the deal:

Have 3 tables, as follows:

Code:
CREATE TABLE [Songs] (
   [MediaKey] varchar (100) NOT NULL PRIMARY KEY,
   [Title] varchar (255),
   [Artist] varchar (255),
       etc...
);

CREATE TABLE [Stations]   (
   [StationId] varchar (100) NOT NULL PRIMARY KEY,
   [MembershipId] varchar (100),
   [Name] varchar (100),
   [Description] varchar (255)
);

CREATE TABLE [StationItems]   (
   [StationId] varchar (100) NOT NULL,
   [MediaKey] varchar (100) NOT NULL,
   [ItemIndex] int
);


Quite simply, I need the ability to map Stations to a list of one or more StationItems, but I'd like my domain model to return Songs as a Child of Stations. All Songs are mapped elsewhere for save/update purposes, and I just need to have the ability to do an add/lookup for Stations in this context.

Here are my classes (at least the two that I'm struggling with):

Code:
    public partial class StationInfoType {
       
        private string membershipIdField;
       
        private string stationIdField;
       
        private string nameField;
       
        private string descriptionField;

        private StationItemsDetailType stationItemField;
       
        /// <remarks/>
        public string MembershipId {
            get {
                return this.membershipIdField;
            }
            set {
                this.membershipIdField = value;
            }
        }
       
        /// <remarks/>
        public string StationId {
            get {
                return this.stationIdField;
            }
            set {
                this.stationIdField = value;
            }
        }
       
        /// <remarks/>
        public string Name {
            get {
                return this.nameField;
            }
            set {
                this.nameField = value;
            }
        }
       
        /// <remarks/>
        public string Description {
            get {
                return this.descriptionField;
            }
            set {
                this.descriptionField = value;
            }
        }

        public StationItemsDetailType Songs
        {
            get
            {
                return this.stationItemField;
            }
            set
            {
                this.stationItemField = value;
            }
        }
       
    }



    public partial class StationItemsDetailType
    {
        private string idField;

        private string stationIdField;

        private IList<SongInfoType> songField = new System.Collections.Generic.List<SongInfoType>();


        public string Id
        {
            get
            {
                return this.idField;
            }
            set
            {
                this.idField = value;
            }
        }

        public string StationId
        {
            get
            {
                return this.stationIdField;
            }
            set
            {
                this.stationIdField = value;
            }
        }
        /// <remarks/>
        [XmlIgnore]
        public IList<SongInfoType> Song
        {
            get
            {
                return this.songField;
            }
            set
            {
                this.songField = value;
            }
        }

        [XmlElement("Song")]
        public System.Collections.Generic.List<SongInfoType> DoNotUse_SerializedSong
        {
            get
            {
                IList<SongInfoType> genericList = new List<SongInfoType>();
                foreach (SongInfoType o in this.songField)
                    genericList.Add(o);

                return genericList as List<SongInfoType>;
            }
            set
            {
                this.songField = value;
            }
        }
    }

I have to believe that this is relatively simple -- any ideas/help would be greatly appreciated.


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.