These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Not saving update of date?
PostPosted: Fri Mar 09, 2007 9:51 pm 
Newbie

Joined: Fri Jan 12, 2007 9:54 am
Posts: 4
NHibernate is working fine except for this one odd problem. I load an object, change a date field, then Update it. Does not save the data though.

Here is the method:

Code:
           
Dim task As BusinessTaskVw = NHibernateHelper.Load(GetType(BusinessTaskVw), taskId)
            task.DateCompleted = Date.Now
            NHibernateHelper.Update(task)


And thehelper method:

Code:

            Dim session As ISession = Nothing
            Dim tx As ITransaction = Nothing

            Try

                session = NHibernateHelper.GetCurrentSession()
                tx = session.BeginTransaction()
                session.Update(entity)

            Finally
                If Not tx Is Nothing Then
                    tx.Commit()
                End If
                If Not session Is Nothing Then
                    NHibernateHelper.CloseSession()
                End If
            End Try


The mapping file:

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
   <class name="ca.bc.gov.cserv.lgis.businessentity.BusinessTaskVw,ca.bc.gov.cserv.lgis.businessentity" table="BUSINESS_TASK_VW" lazy="false" mutable="false">

      <id name="Id" column="ID" type="Decimal">
         <generator class="sequence">
            <param name="sequence">BUSINESS_TASK_VW_seq</param>
         </generator>
      </id>
      <property column="TASK_TYPE_CODE" type="String" name="TaskTypeCode" />
      <property column="OBJECT_TYPE_CODE" type="String" name="ObjectTypeCode" />
      <property column="OBJECT_ID" type="Decimal" name="ObjectId" />
      <property column="ROLE_CODE" type="String" name="RoleCode" />
      <property column="COMMENTS" type="String" name="Comments" />
      <property column="DATE_ASSIGNED" type="DateTime" name="DateAssigned" />
      <property column="DATE_STARTED" type="DateTime" name="DateStarted" />
      <property column="DATE_COMPLETED" type="DateTime" name="DateCompleted" />
      
   </class>
</hibernate-mapping>


And finally the log:

Code:
2007-03-09 17:50:00,391 [7] DEBUG ca.bc.gov.cserv.frameworks.dataaccess.NHibernateHelper - Update Start
2007-03-09 17:50:00,391 [7] DEBUG ca.bc.gov.cserv.frameworks.dataaccess.NHibernateHelper - GetCurrentSession Start
2007-03-09 17:50:00,391 [7] DEBUG NHibernate.Impl.SessionImpl - opened session
2007-03-09 17:50:00,391 [7] DEBUG ca.bc.gov.cserv.frameworks.dataaccess.NHibernateHelper - GetCurrentSession End
2007-03-09 17:50:00,391 [7] DEBUG NHibernate.Transaction.AdoTransaction - begin
2007-03-09 17:50:00,391 [7] DEBUG NHibernate.Connection.DriverConnectionProvider - Obtaining IDbConnection from Driver
2007-03-09 17:50:00,391 [7] DEBUG NHibernate.Impl.SessionImpl - immutable instance passed to doUpdate(), locking
2007-03-09 17:50:00,391 [7] DEBUG NHibernate.Impl.SessionImpl - reassociating transient instance: [ca.bc.gov.cserv.lgis.businessentity.BusinessTaskVw#13]
2007-03-09 17:50:00,391 [7] DEBUG NHibernate.Transaction.AdoTransaction - commit
2007-03-09 17:50:00,391 [7] DEBUG NHibernate.Impl.SessionImpl - flushing session
2007-03-09 17:50:00,391 [7] DEBUG NHibernate.Impl.SessionImpl - Flushing entities and processing referenced collections
2007-03-09 17:50:00,391 [7] DEBUG NHibernate.Impl.SessionImpl - Processing unreferenced collections
2007-03-09 17:50:00,391 [7] DEBUG NHibernate.Impl.SessionImpl - scheduling collection removes/(re)creates/updates
2007-03-09 17:50:00,391 [7] DEBUG NHibernate.Impl.SessionImpl - Flushed: 0 insertions, 0 updates, 0 deletions to 1 objects
2007-03-09 17:50:00,391 [7] DEBUG NHibernate.Impl.SessionImpl - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
2007-03-09 17:50:00,391 [7] DEBUG NHibernate.Impl.Printer - listing entities:
2007-03-09 17:50:00,391 [7] DEBUG NHibernate.Impl.Printer - ca.bc.gov.cserv.lgis.businessentity.BusinessTaskVw{ObjectTypeCode=APPL, DateAssigned=3/9/2007, RoleCode=TECH, DateCompleted=3/9/2007, Id=13, DateStarted=null, TaskTypeCode=TECHREVIEW, ObjectId=178, Comments=tech review}
2007-03-09 17:50:00,391 [7] DEBUG NHibernate.Impl.SessionImpl - executing flush
2007-03-09 17:50:00,391 [7] DEBUG NHibernate.Impl.SessionImpl - post flush
2007-03-09 17:50:00,391 [7] DEBUG NHibernate.Impl.SessionImpl - transaction completion
2007-03-09 17:50:00,391 [7] DEBUG NHibernate.Transaction.AdoTransaction - running AdoTransaction.Dispose()
2007-03-09 17:50:00,391 [7] DEBUG ca.bc.gov.cserv.frameworks.dataaccess.NHibernateHelper - CloseSession Start
2007-03-09 17:50:00,391 [7] DEBUG NHibernate.Impl.SessionImpl - closing session
2007-03-09 17:50:00,391 [7] DEBUG NHibernate.Impl.SessionImpl - disconnecting session
2007-03-09 17:50:00,391 [7] DEBUG NHibernate.Connection.ConnectionProvider - Closing connection
2007-03-09 17:50:00,391 [7] DEBUG NHibernate.Impl.SessionImpl - transaction completion
2007-03-09 17:50:00,391 [7] DEBUG ca.bc.gov.cserv.frameworks.dataaccess.NHibernateHelper - CloseSession End
2007-03-09 17:50:00,391 [7] DEBUG ca.bc.gov.cserv.frameworks.dataaccess.NHibernateHelper - Update End


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 11, 2007 9:28 pm 
Regular
Regular

Joined: Tue Aug 08, 2006 4:28 am
Posts: 96
Location: Hong Kong
From NHibernate Reference Document
Quote:
Immutable classes, mutable="false", may not be updated or deleted by the application. This allows NHibernate to make some minor performance optimizations


set mutable="true" if you made it false by mistake.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 12, 2007 1:59 pm 
Newbie

Joined: Fri Jan 12, 2007 9:54 am
Posts: 4
DOH!

Thanks for pointing out the obvious!

Don


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.