You are modifying an instance that you didn't retrieve using that session,
so NH has no way of knowing the previous value of the property.
I don't know what kind of app this is (desktop, web, etc), but the proper
pattern to update entities without headaches is:
- open the session (this is usually done in a lower level layer, like an
IHttpModule)
- start a transaction
- retrieve the persistent instance from the open session
- make changes
- commit

    Diego


On Mon, Jul 19, 2010 at 02:30, onit <[email protected]> wrote:

> NHibernate 2.1.2GA
>
> mapping
>
> <?xml version="1.0" encoding="utf-8" ?>
> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
>        <class name="TreeViewForBD.Data.Property.PGenericProperty,FondData"
> table="P_GENERIC_PROPERTY" lazy="true" dynamic-insert="true" dynamic-
> update="true">
>
>                <id access="nosetter.lowercase-underscore"  name="InstanceS"
> column="INSTANCE_S" type="String" >
>                        <generator class="assigned"/>
>                </id>
>                <property access="nosetter.lowercase-underscore"
> column="ACTIVITY_S"
> name="ActivityS" type="String"/>
>
>    <join table="P_GENERIC_PROPERTY_LU" optional="true">
>      <key column="INSTANCE_S"/>
>      <property access="nosetter.lowercase-underscore"
> column="LAST_UPDATED" type="DateTime" name="LastUpdated"/>
>    </join>
>  </class>
> </hibernate-mapping>
>
> Problem reproduction:
> =================
>
> PGenericProperty pgp = new PGenericProperty()
> pgp.InstanceS = "1";
>
> ISession _session = factory.OpenSession();
> _session.Save(pgp);
>
> SQL:
> INSERT INTO P_GENERIC_PROPERTY (INSTANCE_S) VALUES     ('1')
>
> Next:
>
> pgp.LastUpdated = DateTime.Now;
> ISession _session1 = factory.OpenSession(); // new session
> _session.Update(pgp);
>
> SQL:
> UPDATE P_GENERIC_PROPERTY SET    ACTIVITY_S = NULL /* @p0_0 */, WHERE
> INSTANCE_S = '4225c2a8e7e440aa60c' /* @p77_0 */
>
> UPDATE P_GENERIC_PROPERTY_LU SET    LAST_UPDATED =
> '2010-07-19T09:00:15.00' /* @p0 */
> WHERE  INSTANCE_S = '4225c2a8e7e440aa60c' /* @p1 */
>
> UPDATE  instead INSERT !!!
>
> Not exists this row in table P_GENERIC_PROPERTY_LU.
> (select_before_update in hbm don't help)
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to