﻿<?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>Sebastijan Pistotnik commented on NHibernate - &lt;natural-id/&gt;</title><description>Ups...sorry for the question...I found it...it seems that you can add as many properties as you need...I just wonder now what would Restrictions.NaturalId() return in this case...
</description><link>http://ayende.com/4061/nhibernate-natural-id#comment21</link><guid>http://ayende.com/4061/nhibernate-natural-id#comment21</guid><pubDate>Wed, 01 Jul 2009 00:27:57 GMT</pubDate></item><item><title>Sebastijan Pistotnik commented on NHibernate - &lt;natural-id/&gt;</title><description>Scenario:
  
Let us assume that on class User we use soft deletable feature, so there is another property IsDeleted added. To create an unique constraint in a database, we must add additional field to Username and that is for example DateCreated field, since othewise soft deleting will not work properly. Can natural-id be composed of two properties (Username And DateCreated); composite class with equals and hash?
</description><link>http://ayende.com/4061/nhibernate-natural-id#comment20</link><guid>http://ayende.com/4061/nhibernate-natural-id#comment20</guid><pubDate>Wed, 01 Jul 2009 00:16:07 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate - &lt;natural-id/&gt;</title><description>Yes, as I said
  
NH-1852
</description><link>http://ayende.com/4061/nhibernate-natural-id#comment19</link><guid>http://ayende.com/4061/nhibernate-natural-id#comment19</guid><pubDate>Thu, 25 Jun 2009 12:57:35 GMT</pubDate></item><item><title>Carlos Fortes commented on NHibernate - &lt;natural-id/&gt;</title><description>Uff sorry for the last comment.
  
  
I was thinking in:
  
  
    class name="AdministrativeFile"
  
    		 table="AdministrativeFiles"
  
  
    	id name="Id"&gt;
  
    	/id&gt;
  
       natural-id mutable="false"
  
		property name="FileNumber" generator="CustomGeneratorInheritedFromHilo"/
  
	/natural-id
  
  or better (use 
&lt;natural-id in the same manner that 
&lt;id)     	natural-id name="FileNumber"
  
               generator class="CustomGeneratorInheritedFromHilo"/
  
/natural-id
  
/class
  
  
Natural-id is the real id, but we use other (invented)  id ONLY for convenience.
&gt;</description><link>http://ayende.com/4061/nhibernate-natural-id#comment18</link><guid>http://ayende.com/4061/nhibernate-natural-id#comment18</guid><pubDate>Thu, 25 Jun 2009 11:29:07 GMT</pubDate></item><item><title> Carlos Fortes commented on NHibernate - &lt;natural-id/&gt;</title><description>I was thinking in:
  
  
&lt;class  
    		 table="AdministrativeFiles"&gt;
  
  
&lt;id  
&lt;generator  
&gt;  
  
&lt;natural-id  
&lt;property  
&gt;  
  
  or better (use 
&lt;natural-id in the same manner that 
&lt;id)
  
  
&lt;natural-id  
&lt;generator  
&gt;  
  
  
  
Natural-id is the real id, but we use other (invented)  id ONLY for convenience.
</description><link>http://ayende.com/4061/nhibernate-natural-id#comment17</link><guid>http://ayende.com/4061/nhibernate-natural-id#comment17</guid><pubDate>Thu, 25 Jun 2009 11:24:36 GMT</pubDate></item><item><title>Carlos Fortes commented on NHibernate - &lt;natural-id/&gt;</title><description>Yes and no.  That is the use of generators for any property and for any purpose (not only generate unique id for 
&lt;natural).  But yes that the idea.
&gt;</description><link>http://ayende.com/4061/nhibernate-natural-id#comment16</link><guid>http://ayende.com/4061/nhibernate-natural-id#comment16</guid><pubDate>Thu, 25 Jun 2009 10:59:04 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate - &lt;natural-id/&gt;</title><description>You seems to be looking for this:
  
[http://nhjira.koah.net/browse/NH-1852](http://nhjira.koah.net/browse/NH-1852)</description><link>http://ayende.com/4061/nhibernate-natural-id#comment15</link><guid>http://ayende.com/4061/nhibernate-natural-id#comment15</guid><pubDate>Thu, 25 Jun 2009 10:32:28 GMT</pubDate></item><item><title>Carlos Fortes commented on NHibernate - &lt;natural-id/&gt;</title><description>Yes, but what if i want use a database sequence in order to obtain the correlative number? I can create a class for that, but i see more more natural use an id generator becouse it use database access and we use nhibernate for that work.
</description><link>http://ayende.com/4061/nhibernate-natural-id#comment14</link><guid>http://ayende.com/4061/nhibernate-natural-id#comment14</guid><pubDate>Thu, 25 Jun 2009 08:18:04 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate - &lt;natural-id/&gt;</title><description>Isn't that why you have field initializer for?
</description><link>http://ayende.com/4061/nhibernate-natural-id#comment13</link><guid>http://ayende.com/4061/nhibernate-natural-id#comment13</guid><pubDate>Thu, 25 Jun 2009 07:51:30 GMT</pubDate></item><item><title>Carlos Fortes commented on NHibernate - &lt;natural-id/&gt;</title><description>For example,  "year/correlativeNumber" like administrative file number. It is an ID that we can calculate like an ID, and it is a natural ID becouse user will see that ID and will use it in the bussines process.
</description><link>http://ayende.com/4061/nhibernate-natural-id#comment12</link><guid>http://ayende.com/4061/nhibernate-natural-id#comment12</guid><pubDate>Thu, 25 Jun 2009 07:46:05 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate - &lt;natural-id/&gt;</title><description>What is the usage scenario you have in mind?
</description><link>http://ayende.com/4061/nhibernate-natural-id#comment11</link><guid>http://ayende.com/4061/nhibernate-natural-id#comment11</guid><pubDate>Thu, 25 Jun 2009 07:12:04 GMT</pubDate></item><item><title>Carlos Fortes commented on NHibernate - &lt;natural-id/&gt;</title><description>I would like use  (custom)  id generators  with natural-id. It would be posible?
</description><link>http://ayende.com/4061/nhibernate-natural-id#comment10</link><guid>http://ayende.com/4061/nhibernate-natural-id#comment10</guid><pubDate>Thu, 25 Jun 2009 07:04:12 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate - &lt;natural-id/&gt;</title><description>Oh, no, it will do nothing.
  
If you really care about this scenario, you have to manually place a Flush in the middle
</description><link>http://ayende.com/4061/nhibernate-natural-id#comment9</link><guid>http://ayende.com/4061/nhibernate-natural-id#comment9</guid><pubDate>Tue, 23 Jun 2009 19:06:20 GMT</pubDate></item><item><title>Carlos Cubas commented on NHibernate - &lt;natural-id/&gt;</title><description>I should clarify that the SaveOrUpdate takes a new instance(new User("Carlos")) as follows.
  
  
SaveOrUpdate(new User("Carlos"));
</description><link>http://ayende.com/4061/nhibernate-natural-id#comment8</link><guid>http://ayende.com/4061/nhibernate-natural-id#comment8</guid><pubDate>Tue, 23 Jun 2009 18:39:11 GMT</pubDate></item><item><title>Carlos Cubas commented on NHibernate - &lt;natural-id/&gt;</title><description>This mostly has to do with an issue I've deal with in the past.  
  
Consider the Entity :
  
  
User
  
-Id  //PK
  
-Name //Natural ID (Unique Constraint on DB)
  
  
An error will occur if I:
  
  
Load("Carlos")
  
Delete("Carlos")
  
SaveOrUpdate("Carlos")
  
Flush()
  
  
As per NHibernate flush documentation, the inserts will happen first, tripping the unique constraint on Name on the already existing row on the table.
  
  
I was wondering if with the introduction of a feature such as 
&lt;natural-id whether there was enough context to know that User:Carlos, should instead be handled in a Delete-Insert-Update order during the flush.
  
  
I hope this cleared it up.
  
  
  
  
&gt;</description><link>http://ayende.com/4061/nhibernate-natural-id#comment7</link><guid>http://ayende.com/4061/nhibernate-natural-id#comment7</guid><pubDate>Tue, 23 Jun 2009 18:37:17 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate - &lt;natural-id/&gt;</title><description>Scott,
  
No, it will not.
</description><link>http://ayende.com/4061/nhibernate-natural-id#comment6</link><guid>http://ayende.com/4061/nhibernate-natural-id#comment6</guid><pubDate>Tue, 23 Jun 2009 18:17:09 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate - &lt;natural-id/&gt;</title><description>Carlos,
  
I am not following you
</description><link>http://ayende.com/4061/nhibernate-natural-id#comment5</link><guid>http://ayende.com/4061/nhibernate-natural-id#comment5</guid><pubDate>Tue, 23 Jun 2009 18:12:46 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate - &lt;natural-id/&gt;</title><description>Dave,
  
I wouldn't worry about that too much, the only effect it will have is that for the duration of the cache, you'll be able to find the user by both usernames.
</description><link>http://ayende.com/4061/nhibernate-natural-id#comment4</link><guid>http://ayende.com/4061/nhibernate-natural-id#comment4</guid><pubDate>Tue, 23 Jun 2009 18:08:27 GMT</pubDate></item><item><title>Scott White commented on NHibernate - &lt;natural-id/&gt;</title><description>Will this be used to generate Equals/GetHashCode overrides in the proxies?
</description><link>http://ayende.com/4061/nhibernate-natural-id#comment3</link><guid>http://ayende.com/4061/nhibernate-natural-id#comment3</guid><pubDate>Tue, 23 Jun 2009 17:24:23 GMT</pubDate></item><item><title>Carlos Cubas commented on NHibernate - &lt;natural-id/&gt;</title><description>I wonder if this feature could be used to *improve* on the flush's insert-update-delete order of operation.  Knowing the entity contains a non-mutable natural id gives enough context to know that the flush should do a delete-insert-update instead for this entity.
</description><link>http://ayende.com/4061/nhibernate-natural-id#comment2</link><guid>http://ayende.com/4061/nhibernate-natural-id#comment2</guid><pubDate>Tue, 23 Jun 2009 16:02:37 GMT</pubDate></item><item><title>Dave Harms commented on NHibernate - &lt;natural-id/&gt;</title><description>Good to know, thanks. Any thoughts on how to handle a situation where the natural id *may* change? For instance, I don't allow my web site users to change their own username, but I will on request change it for them. This doesn't happen often - just a few times per year. 
  
  
Do I just call sessionFactory.evict() after changing the natural id?
</description><link>http://ayende.com/4061/nhibernate-natural-id#comment1</link><guid>http://ayende.com/4061/nhibernate-natural-id#comment1</guid><pubDate>Tue, 23 Jun 2009 15:10:16 GMT</pubDate></item></channel></rss>