I would like to know if there is a way how to store classes only with behavior to database with nHibernate.
What I mean. I have a solution where I have used decorator pattern, something like on class diagram

Here is the problem what Iam trying to solve. I have a class ClassWithStoredBehaviorInProperty and has a property DesiredBehavior of type IBehavior. Somewhere else I mix up behavior f.e. var beh = new FlyBehavior(new WalkBehavior(new BatmanBehavior)) and store it in DesiredBehavior property. And here is my question. Is there any way how to store this in database with nHibernate and then Load it correctly or I have to do some workaround. If it is possible, how to map it? Thanks
You can have hierarchical data structures handled by NHibernate. From a database perspective, The Decorator Pattern is simply a hierarchical structure where there is only one child node rather than a collection. There is some introductory information here.
So you can quite easily map subclasses of the same hierarchy using the ‘table per class hierarchy’ approach, where each Decorator becomes a row in the table and points to an Inner Decorator. In your table you use a discriminator column so when retrieving from the database, NHibernate knows what type of class it needs to instantiate. Obviously the ‘code’ that realises the particular behavior associated with each Decorator would not live in the database.