Hi,
Before saying anything stupid again, I have a question :
Is the QueryCache supported for SQLQueries which use a
ResultTransformer ?
I ask this because I got an IndexOutOfRangeException thrown by the
TypeFactory.Disassemble. The exception is thrown because the types
array parameter is empty when one use a result transformer.
The query works when not set cacheable. Here's the code I used in the
QueryCacheFixture test :
[Test]
public void SQLQueryNoCacheWithResultTransformer()
{
Simple simple = new Simple();
simple.Name = "SQLQueryCacheTest";
using( ISession session = OpenSession() )
{
using( ITransaction transaction =
session.BeginTransaction() )
{
session.Save( simple, 1L );
transaction.Commit();
}
}
using( ISession session = OpenSession() )
{
VerySimple result;
using( ITransaction transaction =
session.BeginTransaction() )
{
// Run a second time, just to test the
query cache
result = session
.CreateSQLQuery( "select s.Name
from Simple s where s.Name
= :name" )
.SetResultTransformer(
Transformers.AliasToBean( typeof( VerySimple ) ) )
.SetString( "name",
"SQLQueryCacheTest" )
.UniqueResult<VerySimple>();
transaction.Commit();
}
Assert.IsNotNull( result );
}
using( ISession session = OpenSession() )
{
session.Delete( "from Simple" );
session.Flush();
}
}
[Test]
public void SQLQueryCacheWithResultTransformer()
{
Simple simple = new Simple();
simple.Name = "SQLQueryCacheTest";
using( ISession session = OpenSession() )
{
using( ITransaction transaction =
session.BeginTransaction() )
{
session.Save( simple, 1L );
transaction.Commit();
}
}
using( ISession session = OpenSession() )
{
using( ITransaction transaction =
session.BeginTransaction() )
{
session
.CreateSQLQuery( "select s.Name
from Simple s where s.Name
= :name" )
.SetResultTransformer(
Transformers.AliasToBean( typeof( VerySimple ) ) )
.SetString( "name",
"SQLQueryCacheTest" )
.SetCacheable( true )
.UniqueResult<VerySimple>();
transaction.Commit();
}
VerySimple result;
using( ITransaction transaction =
session.BeginTransaction() )
{
// Run a second time, just to test the
query cache
result = session
.CreateSQLQuery( "select s.Name
from Simple s where s.Name
= :name" )
.SetResultTransformer(
Transformers.AliasToBean( typeof( VerySimple ) ) )
.SetString( "name",
"SQLQueryCacheTest" )
.SetCacheable( true )
.UniqueResult<VerySimple>();
transaction.Commit();
}
Assert.IsNotNull( result );
Assert.AreEqual( 1L, ( long
)session.GetIdentifier( result ) );
}
using( ISession session = OpenSession() )
{
session.Delete( "from Simple" );
session.Flush();
}
}
public class VerySimple
{
string name;
public string Name
{
get { return name; }
set { name = value; }
}
}
I tried with and without transaction around the query. If needed, I'll
send a patch for this test.
Thanks.
Gildas
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---