﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Ayende Rahien commented on NHibernate Mapping – Inheritance</title><description>  
Dave,
  
Please post the full details to nhusers
  
</description><link>http://ayende.com/3941/nhibernate-mapping-inheritance#comment23</link><guid>http://ayende.com/3941/nhibernate-mapping-inheritance#comment23</guid><pubDate>Fri, 05 Jun 2009 13:30:27 GMT</pubDate></item><item><title>dave commented on NHibernate Mapping – Inheritance</title><description>Sorry the code should have been like this. (it seems the commect are accepting my less then tags and parsing them as HTML do I smell XSS attacks)
  
  
&lt;class name="Party"
  
      abstract="true"
  
      table="Parties"&gt;
  
    &lt;id name="Id"&gt;
  
      &lt;generator class="identity"/&gt;
  
    &lt;/id&gt;
  
    &lt;property name="EntityName" column="entity_name"/&gt;
  
    &lt;property name="ShortName" column="short_name"/&gt;
  
  
    &lt;join table="logical_address"&gt;
  
      &lt;key column="address_id"/&gt;
  
      &lt;component name="ContactDetails" class="ContactDetails"&gt;
  
        &lt;property name="EmailAddress" column="email_address"/&gt;
  
        &lt;property name="HomePhone" column="home_phone_number"/&gt;
  
  
  
      &lt;/component&gt;
  
    &lt;/join&gt;
  
  
  
    &lt;joined-subclass  table="individual" name="Individual"&gt;
  
      &lt;key column="party_key"/&gt;
</description><link>http://ayende.com/3941/nhibernate-mapping-inheritance#comment22</link><guid>http://ayende.com/3941/nhibernate-mapping-inheritance#comment22</guid><pubDate>Fri, 05 Jun 2009 03:38:42 GMT</pubDate></item><item><title>dave commented on NHibernate Mapping – Inheritance</title><description>Hi,
  
  
I am doing "table per subclass" with this exact same DB schema, However I also have a related table called Address which links to Party
  
  
The XML mapping file will not allow me to use both joined-subclass for my Company and Invervidual.   When I try to include my address into Party via join. Is there any way around this? (p.s I am only new to nHiberbate)
  
  
for example
  
--------------------------
  
&lt;class  
      abstract="true"
  
      table="Parties"&gt;
  
&lt;id  
&lt;generator  
&gt;  
&lt;property  
  
&lt;join  
&lt;key  
&lt;component  
&lt;property  
        ...... rest of mapping removed for brevity
  
&gt;  
  
  
  
&lt;joined-subclass  
&lt;key  
--------------------------
  
Visial stiduo compains when both joined-subclass and join table are entered I can only do one of the other?
  
  
TIA Dave
&gt;</description><link>http://ayende.com/3941/nhibernate-mapping-inheritance#comment21</link><guid>http://ayende.com/3941/nhibernate-mapping-inheritance#comment21</guid><pubDate>Fri, 05 Jun 2009 03:34:59 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate Mapping – Inheritance</title><description>Chris,
  
On the face of it, I don't see why no.
</description><link>http://ayende.com/3941/nhibernate-mapping-inheritance#comment20</link><guid>http://ayende.com/3941/nhibernate-mapping-inheritance#comment20</guid><pubDate>Tue, 05 May 2009 05:47:57 GMT</pubDate></item><item><title>Chris Nicola commented on NHibernate Mapping – Inheritance</title><description>Can the Unioned-Subclass (or any other approach) be applied to interface classes instead of abstract classes?  If I have two tables which map to classes that implement the same interface can I setup something where I can get all the objects from both classes with one query on the interface class?
</description><link>http://ayende.com/3941/nhibernate-mapping-inheritance#comment19</link><guid>http://ayende.com/3941/nhibernate-mapping-inheritance#comment19</guid><pubDate>Tue, 05 May 2009 00:07:32 GMT</pubDate></item><item><title>Krzysztof Kozmic commented on NHibernate Mapping – Inheritance</title><description>I see,
  
I've read in few places discussion on pros and cons of each approach. However, I think you, as someone who knows NHibernate in and out, could give a much better and in-depth explanation of the topic.
  
  
Maybe some other time then.
</description><link>http://ayende.com/3941/nhibernate-mapping-inheritance#comment18</link><guid>http://ayende.com/3941/nhibernate-mapping-inheritance#comment18</guid><pubDate>Sat, 11 Apr 2009 13:37:35 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate Mapping – Inheritance</title><description>sebastijan,
  
HiLo can generate a unique ID without having to go to the database.
  
It has all the benefits of GUIDs, but without having to deal with the GUID opaque nature.
  
  
</description><link>http://ayende.com/3941/nhibernate-mapping-inheritance#comment17</link><guid>http://ayende.com/3941/nhibernate-mapping-inheritance#comment17</guid><pubDate>Sat, 11 Apr 2009 09:39:19 GMT</pubDate></item><item><title>sebastijanp commented on NHibernate Mapping – Inheritance</title><description>Why is hilo generator "generally much more recommended anyway"? Does it has to do with optimization? What are the benefits over the identity?
</description><link>http://ayende.com/3941/nhibernate-mapping-inheritance#comment16</link><guid>http://ayende.com/3941/nhibernate-mapping-inheritance#comment16</guid><pubDate>Sat, 11 Apr 2009 09:33:59 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate Mapping – Inheritance</title><description>Trent,
  
There are different optimizations and constraints that apply to each of those.
  
See David's comments for some of them.
</description><link>http://ayende.com/3941/nhibernate-mapping-inheritance#comment15</link><guid>http://ayende.com/3941/nhibernate-mapping-inheritance#comment15</guid><pubDate>Sat, 11 Apr 2009 08:13:43 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate Mapping – Inheritance</title><description>alberto &amp; Krzysztof,
  
It is a matter of time and place, actually.
  
Those posts are part of the prep work for the NH course that I am about to give in May.
  
They represent about 3 hours of discussion of scenarios, alternatives and motives. Pretty hard to put into words by typing them.
  
And most of the info is already out there.
</description><link>http://ayende.com/3941/nhibernate-mapping-inheritance#comment14</link><guid>http://ayende.com/3941/nhibernate-mapping-inheritance#comment14</guid><pubDate>Sat, 11 Apr 2009 08:12:10 GMT</pubDate></item><item><title>huey commented on NHibernate Mapping – Inheritance</title><description>@justin
  
  
Thanks, I'm stupid and glossed over the fact that session.get(userID) was grabbing all of the potential data for employee and vendor so I could later cast appropriately.
  
</description><link>http://ayende.com/3941/nhibernate-mapping-inheritance#comment13</link><guid>http://ayende.com/3941/nhibernate-mapping-inheritance#comment13</guid><pubDate>Sat, 11 Apr 2009 05:11:02 GMT</pubDate></item><item><title>Trent Foley commented on NHibernate Mapping – Inheritance</title><description>It seems to me that 95% of the time you would want to use the first method mentioned (Table per Hierarchy).  This has been the approach I have taken to date, and has been painless so far.  The other 5% of the time I imagine would be due to having to map to an existing database, or you are working with a DBA who is a Normilazation Nazi.
</description><link>http://ayende.com/3941/nhibernate-mapping-inheritance#comment12</link><guid>http://ayende.com/3941/nhibernate-mapping-inheritance#comment12</guid><pubDate>Fri, 10 Apr 2009 18:00:03 GMT</pubDate></item><item><title>David commented on NHibernate Mapping – Inheritance</title><description>@alberto and @Krzysztof
  
from my limited understanding.
  
table per concrete class - fastest, harder to do polymorphing, bad thing you have to update all the tables if there is a change at the parent class level.
  
  
table per hierarchy - fast, but your columns cannot must allow nulls (as multiple classes will not use them), easy for reports.
  
  
table per subclass - this is meant to be the slowest (for large projects), I have no proof, but it the best way for normalisation, clean data. So the design looks nicer.
  
  
the books i would reconmend
  
NHibernate in Action, this has a section on this.
  
Patterns of Enterprise Application Architecture 
  
  
Also thank you Ayende for doing these posts.. I am finding them great for reference!
  
</description><link>http://ayende.com/3941/nhibernate-mapping-inheritance#comment11</link><guid>http://ayende.com/3941/nhibernate-mapping-inheritance#comment11</guid><pubDate>Fri, 10 Apr 2009 17:24:57 GMT</pubDate></item><item><title>Dmitry commented on NHibernate Mapping – Inheritance</title><description>I did not know about the union class either.
  
  
I do not think it has mentioned that you can use common base classes or interfaces to do polymorphic queries. 
  
  
So commands like
  
  
session.CreateCriteria(typeof(object)).List()
  
or
  
session.CreateCriteria(typeof(IEntity)).List() (assuming it's a common interface for the entities)
  
  
are legal in NHibernate.
</description><link>http://ayende.com/3941/nhibernate-mapping-inheritance#comment10</link><guid>http://ayende.com/3941/nhibernate-mapping-inheritance#comment10</guid><pubDate>Fri, 10 Apr 2009 17:17:14 GMT</pubDate></item><item><title>justin commented on NHibernate Mapping – Inheritance</title><description>@huey
  
  
Polymorphism is your friend.
  
User user = session.Get(userId);
  
Vendor vendor = user as Vendor;
  
Employee employee = user as Employee;
  
  
Lookup the "as" and "is" keywords and also remember you can do explicit casting Vendor vendor = (Vendor)user;
</description><link>http://ayende.com/3941/nhibernate-mapping-inheritance#comment9</link><guid>http://ayende.com/3941/nhibernate-mapping-inheritance#comment9</guid><pubDate>Fri, 10 Apr 2009 16:44:16 GMT</pubDate></item><item><title>huey commented on NHibernate Mapping – Inheritance</title><description>Dumb question.  I might have to make a website for our vendors.  So it is going to have type user and a user might be an employee or vendor.  Both employee / vendor will share the same user table and have unique user id's.  This seems to fit in with inheritance mapping in NH.
  
  
The thing is, in all cases I'm going to start with a user id and the first thing I'm going to want to do is figure out if the user is an employee or a vendor.  So it might be something like:
  
  
User user = session.get
&lt;user(userID);
  
if(user.discriminator == "vendor")
  
{
  
vendor = session.get
&lt;vendor(user.ID);
  
}
  
else
  
{
  
employee = session.get
&lt;employee(user.ID);
  
}
  
  
I feel like I'm missing the whole point / benefit of NH inheritance mapping.
  
  
Any suggestions?
&gt;</description><link>http://ayende.com/3941/nhibernate-mapping-inheritance#comment8</link><guid>http://ayende.com/3941/nhibernate-mapping-inheritance#comment8</guid><pubDate>Fri, 10 Apr 2009 15:31:43 GMT</pubDate></item><item><title>Tomasz Modelski commented on NHibernate Mapping – Inheritance</title><description>@ meo : check the date of this news .... :-)
</description><link>http://ayende.com/3941/nhibernate-mapping-inheritance#comment7</link><guid>http://ayende.com/3941/nhibernate-mapping-inheritance#comment7</guid><pubDate>Fri, 10 Apr 2009 11:57:42 GMT</pubDate></item><item><title>alberto commented on NHibernate Mapping – Inheritance</title><description>I'm with Krzysztof. It's something I've missed in the series. It feels like some scenarios would help to understand when to use each approach.
  
  
</description><link>http://ayende.com/3941/nhibernate-mapping-inheritance#comment6</link><guid>http://ayende.com/3941/nhibernate-mapping-inheritance#comment6</guid><pubDate>Fri, 10 Apr 2009 11:54:51 GMT</pubDate></item><item><title>meo commented on NHibernate Mapping – Inheritance</title><description>Did ya read this?
  
  
[blog.wekeroad.com/.../subsonic-to-acquire-nhibe...](http://blog.wekeroad.com/subsonic/subsonic-to-acquire-nhibernate/)</description><link>http://ayende.com/3941/nhibernate-mapping-inheritance#comment5</link><guid>http://ayende.com/3941/nhibernate-mapping-inheritance#comment5</guid><pubDate>Fri, 10 Apr 2009 09:31:18 GMT</pubDate></item><item><title>Krzysztof Kozmic commented on NHibernate Mapping – Inheritance</title><description>I didn't know about union-subclass. Interesting. There's one thing I think would make a great addition to these posts - insight. Showing the mappings and SQL in a very manual-like way is sure great but I wish you took it one step further and talked about non-obvious strengths and weaknesses of each approach.
  
  
Good to see you blogging regularly again :)
</description><link>http://ayende.com/3941/nhibernate-mapping-inheritance#comment4</link><guid>http://ayende.com/3941/nhibernate-mapping-inheritance#comment4</guid><pubDate>Fri, 10 Apr 2009 07:18:09 GMT</pubDate></item><item><title>pcm commented on NHibernate Mapping – Inheritance</title><description>As communicated in the email. I am open to delete this comment if it had hurt you. I love what you are doing for the community.
  
  
I am also changing my name to acronym. And Also not using a link if that makes you happy.
</description><link>http://ayende.com/3941/nhibernate-mapping-inheritance#comment3</link><guid>http://ayende.com/3941/nhibernate-mapping-inheritance#comment3</guid><pubDate>Fri, 10 Apr 2009 06:23:32 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate Mapping – Inheritance</title><description>Hire,
  
a) please use a real name, not a ad.
  
b) I don't know if you noticed, but I didn't mention NH Prof in these, and they are talking about basic feature of NH.
</description><link>http://ayende.com/3941/nhibernate-mapping-inheritance#comment2</link><guid>http://ayende.com/3941/nhibernate-mapping-inheritance#comment2</guid><pubDate>Fri, 10 Apr 2009 06:00:50 GMT</pubDate></item><item><title>HireDotnetexpert commented on NHibernate Mapping – Inheritance</title><description>Although these posts are geared towards your COMMERCIAL product, they are very helpful. 
</description><link>http://ayende.com/3941/nhibernate-mapping-inheritance#comment1</link><guid>http://ayende.com/3941/nhibernate-mapping-inheritance#comment1</guid><pubDate>Fri, 10 Apr 2009 05:49:51 GMT</pubDate></item></channel></rss>