-->
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: Why dynamic-update="true" doesn't work for me?
PostPosted: Mon Sep 19, 2005 4:16 pm 
Beginner
Beginner

Joined: Wed Oct 05, 2005 5:35 am
Posts: 47
Location: France
Hi guys,

I am using 9.1.0 and playing with it can't seem to make dynamic-update="true" work as I expect it should... Am I missing something?
Here are some details.
---------MAPPING-----------
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class dynamic-update="true" name="d001.Business.Test,d001.Business" table="Test" >
<id name="Id" column="id" type="integer"> <generator class="identity" /> </id>
<property name="Name" column= "Name" type="String" /> <property name="Type" column= "Type" type="integer" />
</class>
--CLASS:
Imports System.Collections
Public Class Test
Private _id As Integer
Private _name As String
Private _type As Integer

Public Property Id() As Integer
Get
Return _id
End Get
Set(ByVal Value As Integer)
_id = Value
End Set
End Property

Public Property Name() As String
Get
Return _name
End Get
Set(ByVal Value As String)
_name = Value
End Set
End Property

Public Property Type() As Integer
Get
Return _type
End Get
Set(ByVal Value As Integer)
_type = Value
End Set
End Property
End Class
--------------VALUE CHANGE: --------------

Private Sub SaveButton_Click()
currentTest.Name = TextBox1.Text
Dim xx As TestHelper = New TestHelper
xx.Save(currentTest)
End Sub
----------TestHelper :-------------------
Public Sub Save(ByVal test As Test)
Dim dal As myDataAccess = New myDataAccess
dal.Save(test)
End Sub
--------------SAVE SUB in DAL:-----
tx = h_session.BeginTransaction()
h_session.SaveOrUpdate(item) 'here item As Object
------------SOME DEBUG:----
INFO 6068 NHibernate.Cfg.Configuration - Found mapping documents in assembly: d001.Business.Test.hbm.xml
INFO 6068 NHibernate.Dialect.Dialect - Using dialect: NHibernate.Dialect.MsSql2000Dialect
INFO 6068 NHibernate.Cfg.Binder - Mapping class: d001.Business.Test -> Test
DEBUG 6068 NHibernate.Cfg.Binder - Mapped property: Id -> id, type: Int32
DEBUG 6068 NHibernate.Cfg.Binder - Mapped property: Name -> Name, type: String
DEBUG 6068 NHibernate.Cfg.Binder - Mapped property: Type -> Type, type: Int32

....

DEBUG 6068 NHibernate.Connection.DriverConnectionProvider - Obtaining IDbConnection from Driver
DEBUG 6068 NHibernate.Impl.SessionImpl - search: Test
DEBUG 6068 NHibernate.Impl.SessionImpl - criteria: System.Collections.ArrayList
DEBUG 6068 NHibernate.Impl.SessionImpl - flushing session
DEBUG 6068 NHibernate.Impl.SessionImpl - Flushing entities and processing referenced collections
DEBUG 6068 NHibernate.Impl.SessionImpl - Processing unreferenced collections
DEBUG 6068 NHibernate.Impl.SessionImpl - Processed 0 unreachable collections.
DEBUG 6068 NHibernate.Impl.SessionImpl - scheduling collection removes/(re)creates/updates
DEBUG 6068 NHibernate.Impl.SessionImpl - Processed 0 for recreate (0), remove (0), and update (0)
DEBUG 6068 NHibernate.Impl.SessionImpl - Flushed: 0 insertions, 0 updates, 0 deletions to 0 objects
DEBUG 6068 NHibernate.Impl.SessionImpl - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
DEBUG 6068 NHibernate.Impl.SessionImpl - dont need to execute flush
DEBUG 6068 NHibernate.Impl.BatcherImpl - Opened new IDbCommand, open IDbCommands :1
DEBUG 6068 NHibernate.Impl.BatcherImpl - Building an IDbCommand object for the SqlString: SELECT this.id as id0_, this.Type as Type0_, this.Name as Name0_ FROM Test this WHERE 1=1
INFO 6068 NHibernate.Loader.Loader - SELECT this.id as id0_, this.Type as Type0_, this.Name as Name0_ FROM Test this WHERE 1=1
DEBUG 6068 NHibernate.SQL - SELECT this.id as id0_, this.Type as Type0_, this.Name as Name0_ FROM Test this WHERE 1=1
DEBUG 6068 NHibernate.Impl.BatcherImpl - Opened Reader, open Readers :1
DEBUG 6068 NHibernate.Loader.Loader - processing result set
DEBUG 6068 NHibernate.Type.NullableType - returning '1' as column: id0_
DEBUG 6068 NHibernate.Loader.Loader - result row: 1
DEBUG 6068 NHibernate.Loader.Loader - Initializing object from DataReader: 1
DEBUG 6068 NHibernate.Loader.Loader - Hydrating entity: d001.Business.Test#1
DEBUG 6068 NHibernate.Type.NullableType - returning '1' as column: Type0_
DEBUG 6068 NHibernate.Type.NullableType - returning 'John' as column: Name0_
DEBUG 6068 NHibernate.Type.NullableType - returning '2' as column: id0_
...
DEBUG 6068 NHibernate.Loader.Loader - done processing result set (1 rows)
DEBUG 6068 NHibernate.Driver.NHybridDataReader - running NHybridDataReader.Dispose()
DEBUG 6068 NHibernate.Impl.BatcherImpl - Closed Reader, open Readers :0
DEBUG 6068 NHibernate.Impl.BatcherImpl - Closed IDbCommand, open IDbCommands :0
DEBUG 6068 NHibernate.Loader.Loader - total objects hydrated: 1
DEBUG 6068 NHibernate.Impl.SessionImpl - resolving associations for: [d001.Business.Test#1]
DEBUG 6068 NHibernate.Impl.SessionImpl - done materializing entity [d001.Business.Test#1]

DEBUG 6068 NHibernate.Impl.SessionImpl - initializing non-lazy collections
DEBUG 6068 NHibernate.Transaction.AdoTransaction - commit
DEBUG 6068 NHibernate.Impl.SessionImpl - flushing session
DEBUG 6068 NHibernate.Impl.SessionImpl - Flushing entities and processing referenced collections
DEBUG 6068 NHibernate.Impl.SessionImpl - Processing unreferenced collections
DEBUG 6068 NHibernate.Impl.SessionImpl - Processed 0 unreachable collections.
DEBUG 6068 NHibernate.Impl.SessionImpl - scheduling collection removes/(re)creates/updates
DEBUG 6068 NHibernate.Impl.SessionImpl - Processed 0 for recreate (0), remove (0), and update (0)
DEBUG 6068 NHibernate.Impl.SessionImpl - Flushed: 0 insertions, 0 updates, 0 deletions to 1 objects
DEBUG 6068 NHibernate.Impl.SessionImpl - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
DEBUG 6068 NHibernate.Impl.SessionImpl - executing flush
DEBUG 6068 NHibernate.Impl.SessionImpl - post flush
DEBUG 6068 NHibernate.Transaction.AdoTransaction - running AdoTransaction.Dispose()
DEBUG 6068 NHibernate.Impl.SessionImpl - transaction completion

..

INFO 6068 NHibernate.Cfg.Configuration - processing one-to-many association mappings
INFO 6068 NHibernate.Cfg.Configuration - processing one-to-one association property references
INFO 6068 NHibernate.Cfg.Configuration - processing foreign key constraints
INFO 6068 NHibernate.Dialect.Dialect - Using dialect: NHibernate.Dialect.MsSql2000Dialect
INFO 6068 NHibernate.Cfg.SettingsFactory - use outer join fetching: True
INFO 6068 NHibernate.Connection.ConnectionProviderFactory - Intitializing connection provider: NHibernate.Connection.DriverConnectionProvider
INFO 6068 NHibernate.Connection.ConnectionProvider - Configuring ConnectionProvider
INFO 6068 NHibernate.Cfg.SettingsFactory - Query language substitutions:
INFO 6068 NHibernate.Cfg.SettingsFactory - cache provider: NHibernate.Cache.HashtableCacheProvider
INFO 6068 NHibernate.Cfg.Configuration - instantiating and configuring caches
INFO 6068 NHibernate.Impl.SessionFactoryImpl - building session factory
DEBUG 6068 NHibernate.Impl.SessionFactoryImpl - instantiating session factory with properties: {hibernate.dialect=NHibernate.Dialect.MsSql2000Dialect, hibernate.connection.connection_string=Data Source=localhost;Database=test;Integrated Security=SSPI;Min Pool Size=2, hibernate.connection.provider=NHibernate.Connection.DriverConnectionProvider, hibernate.connection.driver_class=NHibernate.Driver.SqlClientDriver}
DEBUG 6068 NHibernate.Impl.SessionFactoryObjectFactory - registered: ffe2f9e16f3e494ba670267bd9911cc4(unnamed)
INFO 6068 NHibernate.Impl.SessionFactoryObjectFactory - no name configured
DEBUG 6068 NHibernate.Impl.SessionFactoryImpl - Instantiated session factory
DEBUG 6068 NHibernate.Impl.SessionImpl - opened session
DEBUG 6068 NHibernate.Transaction.AdoTransaction - begin
DEBUG 6068 NHibernate.Connection.DriverConnectionProvider - Obtaining IDbConnection from Driver
DEBUG 6068 NHibernate.Engine.Cascades - unsaved-value strategy NULL
DEBUG 6068 NHibernate.Impl.SessionImpl - SaveOrUpdate() previously saved instance with id: 1
DEBUG 6068 NHibernate.Impl.SessionImpl - updating [d001.Business.Test#1]
DEBUG 6068 NHibernate.Transaction.AdoTransaction - commit
DEBUG 6068 NHibernate.Impl.SessionImpl - flushing session
DEBUG 6068 NHibernate.Impl.SessionImpl - Flushing entities and processing referenced collections
DEBUG 6068 NHibernate.Impl.SessionImpl - Updating entity: [d001.Business.Test#1]
DEBUG 6068 NHibernate.Impl.SessionImpl - Processing unreferenced collections
DEBUG 6068 NHibernate.Impl.SessionImpl - Processed 0 unreachable collections.
DEBUG 6068 NHibernate.Impl.SessionImpl - scheduling collection removes/(re)creates/updates
DEBUG 6068 NHibernate.Impl.SessionImpl - Processed 0 for recreate (0), remove (0), and update (0)
DEBUG 6068 NHibernate.Impl.SessionImpl - Flushed: 0 insertions, 1 updates, 0 deletions to 1 objects
DEBUG 6068 NHibernate.Impl.SessionImpl - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
DEBUG 6068 NHibernate.Impl.SessionImpl - executing flush
DEBUG 6068 NHibernate.Persister.EntityPersister - Updating entity: d001.Business.Test#1
DEBUG 6068 NHibernate.Impl.BatcherImpl - Opened new IDbCommand, open IDbCommands :1
DEBUG 6068 NHibernate.Impl.BatcherImpl - Building an IDbCommand object for the SqlString: UPDATE Test SET Type = :Type, Name = :Name WHERE id = :id
DEBUG 6068 NHibernate.Persister.EntityPersister - Dehydrating entity: d001.Business.Test#1
DEBUG 6068 NHibernate.Type.NullableType - binding '1' to parameter: 0
DEBUG 6068 NHibernate.Type.NullableType - binding 'JohnXXX' to parameter: 1
DEBUG 6068 NHibernate.Type.NullableType - binding '1' to parameter: 2
DEBUG 6068 NHibernate.SQL - UPDATE Test SET Type = @p0, Name = @p1 WHERE id = @p2
DEBUG 6068 NHibernate.Impl.BatcherImpl - Closed IDbCommand, open IDbCommands :0
DEBUG 6068 NHibernate.Impl.SessionImpl - post flush
DEBUG 6068 NHibernate.Transaction.AdoTransaction - running AdoTransaction.Dispose()
DEBUG 6068 NHibernate.Impl.SessionImpl - transaction completion


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 20, 2005 8:45 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
I can't see from your code where sessions are open and closed. In general for dynamic-update to work, your object must be updated in the same session it was loaded in.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 20, 2005 9:51 am 
Beginner
Beginner

Joined: Wed Oct 05, 2005 5:35 am
Posts: 47
Location: France
Thanks a lot Sergey,
That answers the question. I have a separate DAL that works on session-per-request basis for the moment - I'll see what I can do there...


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.