-->
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.  [ 4 posts ] 
Author Message
 Post subject: can't call session.Load twice within the same session
PostPosted: Tue May 17, 2005 1:03 pm 
Newbie

Joined: Tue May 17, 2005 12:36 pm
Posts: 1
I've setup a trivial table of two integers, and am trying this code on it

SimpleTable sm1 = (SimpleTable)session.Load(typeof(SimpleTable), 1);
MessageBox.Show(sm1.Id.ToString());
SimpleTable sm2 = (SimpleTable)session.Load(typeof(SimpleTable), 3);
MessageBox.Show(sm2.Id.ToString());

First call works fine, the second fails with the exception
"could not load object"
{"Invalid index 0 for this OleDbParameterCollection with Count=0." }

Is this a reasonable thing to attempt ? Or should I be using a new session for pretty much every query ?

I'm using nhibernate-0.8.2.0 with
NHibernate.Dialect.SybaseDialect
NHibernate.Driver.OleDbDriver
Provider=Sybase.ASEOLEDBProvider;Server ....and so on

Looking at the code, it appears to be an issue with the way commands are cached in BatcherImpl.cs. The sequence of events is

BatcherImpl.cs creates a new command for the sql
The command has a param created on it for the id number I send in
The command is stored in a hashtable called commands in BatcherImpl.cs
Loader.cs executes the command, and processes the results
Loader.cs calls CloseQueryCommand
This essentially calls Dispose() on the command - which amongst other things erases the parameter from it

Next time I call session.Load on the same table, it retrieves the command from the cache in BatcherImpl.cs and tries to use it. It fails when it tries to setup the parameter bindings, because the command no longer has a parameter in it. Even if this weren't the case, I don't think the command can be reused after Dispose() has been called on it.

If this is a genuine problem, I guess that either Dispose shouldn't be called on the command, or the command should be removed from the commands hashtable as part of CloseQueryCommand


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 17, 2005 2:01 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
You have been hit by the "Firebird/Oracle/OleDb bug" which is being solved now. The fix will be in 0.8.4.


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 18, 2005 3:52 am 
Thanks. I'll work around it until 0.8.4 arrives.


Top
  
 
 Post subject:
PostPosted: Wed May 18, 2005 9:21 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
Or you can take it in NHibernate CVS

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.