﻿<?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>jdn commented on NHibernate Mapping - &lt;any/&gt;</title><description>Well, okay.  I did not get that from the comment(s) that you made, you are usually very clear and direct in what you say.  I don't see how one gets from 'there is no way to actually create a SQL query' to (paraphrasing) 'you can't get good performance from a SQL query in a generic way.'  Apologies if I misconstrued anything you said, never my intention.
  
  
I believe that you can do it in SQL with acceptable performance margins, but that is highly dependent on context and how one defines 'acceptable', so I won't harp on that here.
  
  
Thanks.
</description><link>http://ayende.com/3966/nhibernate-mapping-any#comment18</link><guid>http://ayende.com/3966/nhibernate-mapping-any#comment18</guid><pubDate>Wed, 22 Apr 2009 23:30:16 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate Mapping - &lt;any/&gt;</title><description>jdn,
  
I meant, there is no generic way to do it in SQL that has acceptable performance margins
</description><link>http://ayende.com/3966/nhibernate-mapping-any#comment17</link><guid>http://ayende.com/3966/nhibernate-mapping-any#comment17</guid><pubDate>Wed, 22 Apr 2009 06:20:22 GMT</pubDate></item><item><title>jdn commented on NHibernate Mapping - &lt;any/&gt;</title><description>I didn't 'forget' anything.  I was responding to
  
  
"There is no way to actually create a SQL query that would do that."
  
  
to Mark.  It is possible to write the query for what he asked about.
  
  
To 'generalize' it, you would dynamically generate the SQL (which would require other work, of course) that needed to be executed.
  
  
Note, I'm not saying this is a good thing, but it is possible.
</description><link>http://ayende.com/3966/nhibernate-mapping-any#comment16</link><guid>http://ayende.com/3966/nhibernate-mapping-any#comment16</guid><pubDate>Tue, 21 Apr 2009 16:38:34 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate Mapping - &lt;any/&gt;</title><description>Jdn,
  
a) you forgot that you may have different properties for different entitites. that is, not all entities would have Amount, how do you handle that?
  
b) try to generalize this scenario for a 10 entities scenario, see what happens
  
  
</description><link>http://ayende.com/3966/nhibernate-mapping-any#comment15</link><guid>http://ayende.com/3966/nhibernate-mapping-any#comment15</guid><pubDate>Tue, 21 Apr 2009 16:33:15 GMT</pubDate></item><item><title>jdn commented on NHibernate Mapping - &lt;any/&gt;</title><description>select o.* from [Order] o
  
left join CCPayments on
  
CCPayments.ID = o.PaymentID
  
and o.PaymentType = 'CC'
  
left join WirePayments on
  
WirePayments.ID = o.PaymentID
  
and o.PaymentType = 'Wire'
  
where 
  
CCPayments.Amount = 100
  
or
  
WirePayments.Amount = 100
  
  
  
Given the data Mark listed (3 orders, 2 in CC, 1 in Wire), this returns the correct two rows.
  
  
What am I missing?
</description><link>http://ayende.com/3966/nhibernate-mapping-any#comment14</link><guid>http://ayende.com/3966/nhibernate-mapping-any#comment14</guid><pubDate>Tue, 21 Apr 2009 16:29:31 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate Mapping - &lt;any/&gt;</title><description>Jdn,
  
Please try to formulate that query.
</description><link>http://ayende.com/3966/nhibernate-mapping-any#comment13</link><guid>http://ayende.com/3966/nhibernate-mapping-any#comment13</guid><pubDate>Tue, 21 Apr 2009 16:26:06 GMT</pubDate></item><item><title>jdn commented on NHibernate Mapping - &lt;any/&gt;</title><description>"select order o where o.Payment.Amount = 100"
  
  
"There is no way to actually create a SQL query that would do that."
  
  
There isn't?  What am I missing?  The query is pretty trivial.  Or do you mean there isn't a way to tell NHibernate how to do it?
</description><link>http://ayende.com/3966/nhibernate-mapping-any#comment12</link><guid>http://ayende.com/3966/nhibernate-mapping-any#comment12</guid><pubDate>Tue, 21 Apr 2009 16:09:39 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate Mapping - &lt;any/&gt;</title><description>Kyle,
  
Wait for tomorrow :-)
</description><link>http://ayende.com/3966/nhibernate-mapping-any#comment11</link><guid>http://ayende.com/3966/nhibernate-mapping-any#comment11</guid><pubDate>Tue, 21 Apr 2009 14:13:20 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate Mapping - &lt;any/&gt;</title><description>Craig,
  
By their positions
  
The first is the type, the second is the id.
  
  
</description><link>http://ayende.com/3966/nhibernate-mapping-any#comment10</link><guid>http://ayende.com/3966/nhibernate-mapping-any#comment10</guid><pubDate>Tue, 21 Apr 2009 14:12:56 GMT</pubDate></item><item><title>Kyle Baley commented on NHibernate Mapping - &lt;any/&gt;</title><description>What if you wanted to have a collection of payments on the order?
</description><link>http://ayende.com/3966/nhibernate-mapping-any#comment9</link><guid>http://ayende.com/3966/nhibernate-mapping-any#comment9</guid><pubDate>Tue, 21 Apr 2009 14:10:16 GMT</pubDate></item><item><title>Craig Quillen commented on NHibernate Mapping - &lt;any/&gt;</title><description>How does it know which of the 
&lt;column is the FKey and which is the descriminator?  By their data type?
&gt;</description><link>http://ayende.com/3966/nhibernate-mapping-any#comment8</link><guid>http://ayende.com/3966/nhibernate-mapping-any#comment8</guid><pubDate>Tue, 21 Apr 2009 14:04:42 GMT</pubDate></item><item><title>Daniel Fernandes commented on NHibernate Mapping - &lt;any/&gt;</title><description>@Ayende
  
  
The second I posted my comment I thought I was way off as I've got only small understanding of the NHibernate codebase :)
  
The reason why I think 
&lt;any association as great is that it allows true polymorphic associations between entities instead of having to be limited by the fact that associations have to be between a table to another table.
  
  
Daniel
&gt;</description><link>http://ayende.com/3966/nhibernate-mapping-any#comment7</link><guid>http://ayende.com/3966/nhibernate-mapping-any#comment7</guid><pubDate>Tue, 21 Apr 2009 08:03:15 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate Mapping - &lt;any/&gt;</title><description>Daniel,
  
Fairly easy? Not really.
  
Try extremely hard.
  
Just for kicks, try to write a SQL statement that can do that, they try to generalize this for the whole concept.
  
  
As for being able to query that, any is supposed to be used for special purposes, not for anything, and if you want to query that, just query it from the other side.
  
  
</description><link>http://ayende.com/3966/nhibernate-mapping-any#comment6</link><guid>http://ayende.com/3966/nhibernate-mapping-any#comment6</guid><pubDate>Tue, 21 Apr 2009 07:43:08 GMT</pubDate></item><item><title>Daniel Fernandes commented on NHibernate Mapping - &lt;any/&gt;</title><description>@Ayende
  
  
Isn't it a big limitation that from NH point of view a 
&lt;any relationship is akin of having System.Object on one side ? This is pretty restrictive in term of querying logic.
  
Woudln't it be "fairly" easy to extend the 
&lt;any mapping to have implicit typing instead of System.Object therefore enabling flexible polymorphic associations ?
  
  
Daniel
&gt;</description><link>http://ayende.com/3966/nhibernate-mapping-any#comment5</link><guid>http://ayende.com/3966/nhibernate-mapping-any#comment5</guid><pubDate>Tue, 21 Apr 2009 07:25:05 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate Mapping - &lt;any/&gt;</title><description>Mark,
  
No, we cannot do that.
  
There is no way to actually create a SQL query that would do that.
  
  
</description><link>http://ayende.com/3966/nhibernate-mapping-any#comment4</link><guid>http://ayende.com/3966/nhibernate-mapping-any#comment4</guid><pubDate>Tue, 21 Apr 2009 07:17:31 GMT</pubDate></item><item><title>mark commented on NHibernate Mapping - &lt;any/&gt;</title><description>one question about 
&lt;any, if you map also the IPayment interface with for example the property Amount, there's a way to do queries using this property?
  
  
i mean that i have in the db 3 order
  
1 with CreditCardPayment an Amount = 100,
  
1 with CreditCardPayment an Amount = 50,
  
1 with WirePayment an Amount = 100,
  
  
and i want to do a query as
  
"select order o where o.Payment.Amount = 100"
  
  
it's possible using 
&lt;any?
&gt;</description><link>http://ayende.com/3966/nhibernate-mapping-any#comment3</link><guid>http://ayende.com/3966/nhibernate-mapping-any#comment3</guid><pubDate>Tue, 21 Apr 2009 07:11:18 GMT</pubDate></item><item><title>CaliCoder commented on NHibernate Mapping - &lt;any/&gt;</title><description>nice post!
</description><link>http://ayende.com/3966/nhibernate-mapping-any#comment2</link><guid>http://ayende.com/3966/nhibernate-mapping-any#comment2</guid><pubDate>Tue, 21 Apr 2009 05:34:29 GMT</pubDate></item><item><title>josh commented on NHibernate Mapping - &lt;any/&gt;</title><description>i don't like those scenarios, but I do like how nhib can handle it.
</description><link>http://ayende.com/3966/nhibernate-mapping-any#comment1</link><guid>http://ayende.com/3966/nhibernate-mapping-any#comment1</guid><pubDate>Tue, 21 Apr 2009 04:28:29 GMT</pubDate></item></channel></rss>