-->
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: Polymorphic component
PostPosted: Thu Oct 11, 2007 5:32 am 
Newbie

Joined: Thu Aug 02, 2007 11:20 am
Posts: 4
Is there any way to map a polymorphic (<subclass>) component in v1.2.0GA?

My object model is like this:
Code:
public class DomainClass
    {
        private IStrategy _myStrategy;
        private int _classSpecificState;

        public int ClassSpecificState
        {
            get { return _classSpecificState; }
        }

        public decimal StrategyState
        {
            get { return _myStrategy.SomeState; }
        }

        public void StrategyBehaviour()
        {
            _myStrategy.SomeBehaviour();
        }
    }

    public interface IStrategy
    {
        decimal SomeState{ get;}
        void SomeBehaviour();
    }

    public class StrategyOne : IStrategy
    {
        private decimal _someState;

        #region IStrategy Members

        public decimal SomeState
        {
            get { return _someState; }
        }

        public void SomeBehaviour()
        {
            throw new NotImplementedException();
        }

        #endregion
    }

    public class StrategyTwo : IStrategy
    {

        #region IStrategy Members

        public decimal SomeState
        {
            get { return 0m; }
        }

        public void SomeBehaviour()
        {
            throw new NotImplementedException();
        }

        #endregion
    }


I would like to contain both the DomainClass (& it's associated IStrategy) within the one table. However to do this I would need some way specifying a polymorphic component in my DomainClass hbm file.

Is there any way to do this?


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.