﻿<?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>Jim commented on NHibernate trickery: what happened to my associations?</title><description>What the conclusion?
</description><link>http://ayende.com/4275/nhibernate-trickery-what-happened-to-my-associations#comment13</link><guid>http://ayende.com/4275/nhibernate-trickery-what-happened-to-my-associations#comment13</guid><pubDate>Mon, 02 Nov 2009 22:27:21 GMT</pubDate></item><item><title>David Kemp commented on NHibernate trickery: what happened to my associations?</title><description>@Lothan - that seems to be the problem.
  
NHibernate seems to want a collection called [TrickyBug.User.AllowedPaths#Ayende], but it actually loads a collection called [TrickyBug.User.AllowedPaths#ayende] (based ion the database), so you get a log something like:
  
  
collection fully initialized: [TrickyBug.User.AllowedPaths#Ayende]
  
collection fully initialized: [TrickyBug.User.AllowedPaths#ayende]
  
2 collections initialized for role: TrickyBug.User.AllowedPaths
  
  
Note that it says there were 2 collections loaded! Normally only one would be found for an association like this.
  
  
@ayende - very subtle bug. Well highlighted.
</description><link>http://ayende.com/4275/nhibernate-trickery-what-happened-to-my-associations#comment12</link><guid>http://ayende.com/4275/nhibernate-trickery-what-happened-to-my-associations#comment12</guid><pubDate>Mon, 02 Nov 2009 10:45:26 GMT</pubDate></item><item><title>Jos&amp;#233; Romaniello commented on NHibernate trickery: what happened to my associations?</title><description>An array is not a valid Set. The user will not be saved.
  
I used to have my collections with "private set".
</description><link>http://ayende.com/4275/nhibernate-trickery-what-happened-to-my-associations#comment11</link><guid>http://ayende.com/4275/nhibernate-trickery-what-happened-to-my-associations#comment11</guid><pubDate>Mon, 02 Nov 2009 10:44:23 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate trickery: what happened to my associations?</title><description>Benny,
  
[nhprof.com/.../Alert](http://nhprof.com/Learn/Alert?name=DoNotUseImplicitTransactions)</description><link>http://ayende.com/4275/nhibernate-trickery-what-happened-to-my-associations#comment10</link><guid>http://ayende.com/4275/nhibernate-trickery-what-happened-to-my-associations#comment10</guid><pubDate>Sun, 01 Nov 2009 21:57:30 GMT</pubDate></item><item><title>Scott Muc commented on NHibernate trickery: what happened to my associations?</title><description>Sorry to bring up something off topic but why do you have the line tx.Commit(); line in the 2nd using block? It is just for consistency? I thought the idea of a commit is only when performing updates and inserts.
</description><link>http://ayende.com/4275/nhibernate-trickery-what-happened-to-my-associations#comment9</link><guid>http://ayende.com/4275/nhibernate-trickery-what-happened-to-my-associations#comment9</guid><pubDate>Sun, 01 Nov 2009 19:00:38 GMT</pubDate></item><item><title>Jason Y commented on NHibernate trickery: what happened to my associations?</title><description>Interesting.  One of our apps that interacts with legacy databases had a problem of this exact sort.  Our quick workaround was to normalize the case across tables.  I'm looking forward to details on what's happening here!
</description><link>http://ayende.com/4275/nhibernate-trickery-what-happened-to-my-associations#comment8</link><guid>http://ayende.com/4275/nhibernate-trickery-what-happened-to-my-associations#comment8</guid><pubDate>Sun, 01 Nov 2009 17:56:14 GMT</pubDate></item><item><title>Lothan commented on NHibernate trickery: what happened to my associations?</title><description>I would expect the output to be:
  
  
Ayende
  
\t/meetings
  
\t/users
  
  
since this seems to be the intent of the fetch. However, NHibernate blindly performs a case-sensitive comparison on the join even though the database comparison is case-insensitive.
  
  
More to the point, I question whether this is really a bug in the code or a bug in NHibernate. Even though you requested to load Ayende, the database actually returned ayende and NHIbernate is ignoring that. Shouldn't the data in the database be the key instead of the data in the query?
  
  
Even so, you'll still run into problems in cases in which the collections contain mixed case (e.g. ayende in some records and Ayende in others). We had to work around this issue by creating our own case-insensitive comparer.
</description><link>http://ayende.com/4275/nhibernate-trickery-what-happened-to-my-associations#comment7</link><guid>http://ayende.com/4275/nhibernate-trickery-what-happened-to-my-associations#comment7</guid><pubDate>Sun, 01 Nov 2009 16:57:04 GMT</pubDate></item><item><title>Yitzchok commented on NHibernate trickery: what happened to my associations?</title><description>The problem (I think) is with case-sensitivity 
  
  
What seems to happen is that SqlServer returns the expected result but for some reason Hibernate checks for case-sensitivity when filtering the set (collection).
  
  
What is I think the most interesting part (and probably the bug you are talking about) is that NHibernate returns a User object with the Username "Ayende" (capital A) which isn't in the Database (it should be "ayende"). It looks like NHibernate uses the Get value for the Key (not the value from the Database) which isn't a problem in most cases (int or Guid).
</description><link>http://ayende.com/4275/nhibernate-trickery-what-happened-to-my-associations#comment6</link><guid>http://ayende.com/4275/nhibernate-trickery-what-happened-to-my-associations#comment6</guid><pubDate>Sun, 01 Nov 2009 16:00:15 GMT</pubDate></item><item><title>Benny Thomas commented on NHibernate trickery: what happened to my associations?</title><description>Where is the article/blog why you should use a transaction with commit on a read operation?
  
  
I think I have to read me up on that!
</description><link>http://ayende.com/4275/nhibernate-trickery-what-happened-to-my-associations#comment5</link><guid>http://ayende.com/4275/nhibernate-trickery-what-happened-to-my-associations#comment5</guid><pubDate>Sun, 01 Nov 2009 14:16:33 GMT</pubDate></item><item><title>Markus Zywitza commented on NHibernate trickery: what happened to my associations?</title><description>That should have read:
  
Is it possible to map &lt;set&gt; to ICollection&lt;T&gt; without an IUserCollectionType?
</description><link>http://ayende.com/4275/nhibernate-trickery-what-happened-to-my-associations#comment4</link><guid>http://ayende.com/4275/nhibernate-trickery-what-happened-to-my-associations#comment4</guid><pubDate>Sun, 01 Nov 2009 12:21:15 GMT</pubDate></item><item><title>Markus Zywitza commented on NHibernate trickery: what happened to my associations?</title><description>Is it possible to map 
&lt;set to ICollection
&lt;t without an IUserCollectionType?
&gt;</description><link>http://ayende.com/4275/nhibernate-trickery-what-happened-to-my-associations#comment3</link><guid>http://ayende.com/4275/nhibernate-trickery-what-happened-to-my-associations#comment3</guid><pubDate>Sun, 01 Nov 2009 12:19:05 GMT</pubDate></item><item><title>Will commented on NHibernate trickery: what happened to my associations?</title><description>It is the capitalisation of the username: "ayende" in the Save and "Ayende" (capital A) in the Get.  This is fine for the Get but confuses the loading of the AllowedPaths.  I am guessing that this is because Get issues a SQL query and SQL is not case sensitive and that either the AllowedPaths uses a case sensitive SQL query (which I doubt) or the matching is done in code with a case sensitive comparer.
  
</description><link>http://ayende.com/4275/nhibernate-trickery-what-happened-to-my-associations#comment2</link><guid>http://ayende.com/4275/nhibernate-trickery-what-happened-to-my-associations#comment2</guid><pubDate>Sun, 01 Nov 2009 12:15:58 GMT</pubDate></item><item><title>Tapio Kulmala commented on NHibernate trickery: what happened to my associations?</title><description>Hi!
  
  
"ayende" vs "Ayende"? 
  
  
Non case-sensitive DB?
  
  
Tapio
</description><link>http://ayende.com/4275/nhibernate-trickery-what-happened-to-my-associations#comment1</link><guid>http://ayende.com/4275/nhibernate-trickery-what-happened-to-my-associations#comment1</guid><pubDate>Sun, 01 Nov 2009 12:00:55 GMT</pubDate></item></channel></rss>