"Keyword not supported: 'statement cache size'."

190 views
Skip to first unread message

ssp

unread,
Aug 11, 2009, 10:13:10 PM8/11/09
to Fluent NHibernate
I am trying to connect to an oracle 10g database with the following
configuration. For some reason I keep getting the:

"Keyword not supported: 'statement cache size'." exception. Any ideas?

The code below contains the configuration code.
==============================================
return Fluently.Configure()
.Database( OracleClientConfiguration.Oracle9
.ConnectionString( c => c
.Server( "XXX" )
.Instance( "XXXUser" )
.Username( "XXXUser" )
.Password( "XXXUser" ))
.Cache( c => c
.UseQueryCache()
.ProviderClass<NHibernate.Cache.HashtableCacheProvider>
() )
.ShowSql() )
.Mappings( m =>
m.FluentMappings.AddFromAssemblyOf<Category>() )
.BuildSessionFactory();
===============================================

David R. Longnecker

unread,
Aug 12, 2009, 7:45:14 AM8/12/09
to fluent-n...@googlegroups.com
I see the problem in the FNH code.  I'll update that.  To work around it for now, specify the StatementCacheSize(int) fluent method on your connection string.

Odd no one has ever ran into that.  Whoops.

-dl

James Gregory

unread,
Aug 12, 2009, 8:25:52 AM8/12/09
to fluent-n...@googlegroups.com
Thanks David, hit me with a pull request when you're done.

David R. Longnecker

unread,
Aug 12, 2009, 9:02:54 AM8/12/09
to fluent-n...@googlegroups.com
@james - Master branch has a pull enroute.

@ssp - Sorry about that; the OracleDataClientConfiguration prefers having StatementCacheSize(int) specified.  Since you're using OracleClient, that was probably throwing a fit.  The StatementCacheSize is now optional, so your current configuration string should work like a champ.

-dl

Froggymeister

unread,
Aug 12, 2009, 6:19:36 PM8/12/09
to fluent-n...@googlegroups.com
Hi David,

Am I meant to pull a new version of the code and compile/grab latest binaries?

Anyway...I tried the workaround you suggested with the code now looking like what is below (note the inclusion of StatementCacheSize(100)). Unfortunately the error hasn't disappeared.


==========================================
return Fluently.Configure()
                .Database( OracleClientConfiguration.Oracle9
                 .ConnectionString( c => c
                     .Server( "XXX" )
                     .Instance( "XXXUser" )
                     .Username( "XXXUser" )
                     .Password( "XXXUser" )
                     .StatementCacheSize( 100 ) )

                 .Cache( c => c
                     .UseQueryCache()
                     .ProviderClass<NHibernate.Cache.HashtableCacheProvider>() )
                 .ShowSql() )
                .Mappings( m => m.FluentMappings.AddFromAssemblyOf<Category>() )
                .BuildSessionFactory();
===========================================


I tried another route to solving the problem. Changed the code to look like this:

===========================================
            var cfg = OracleClientConfiguration.Oracle9
                .ConnectionString( c => c
                    .Is( "DATA SOURCE=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.112)(PORT=1521))(CONNECT_DATA=(SERVER = DEDICATED)(SERVICE_NAME=XXX)));PERSIST SECURITY INFO=True;USER ID=XXXUser;Password=XXXUser" ) );

            return Fluently.Configure()
                    .Database( cfg )
                    .Mappings( m => m
                        .FluentMappings.AddFromAssemblyOf<Category>() )
                    .BuildSessionFactory();
===========================================

This code resulted in no errors, but it wouldn't return any results. I am expecting a few rows from the Category table, but returns nothing.

I know I am doing everything right in so far as connecting to the database is concerned. By providing the wrong user details and wrong database names, I receive the expected exceptions.

Code to return the Category table:
===========================================
using ( var session = sessionFactory.OpenSession() )
            {
                using ( session.BeginTransaction() )
                {
                    var category = session.CreateCriteria( typeof( Category ) )
                        .List<Category>();
                    foreach ( var cat in category )
                    {
                       // do something
                    }
                }
            }
===========================================


2009/8/13 David R. Longnecker <tireds...@gmail.com>

David R. Longnecker

unread,
Aug 13, 2009, 8:55:22 AM8/13/09
to fluent-n...@googlegroups.com
Using the connection string below (and with working server, instance, user, pass, and a mapping object), I connected to an Oracle i9 v9.2.0.8 database without any errors.  Unfortunately, not being the "DBA dude" I don't have access to the dba schema to see if, perhaps, statement cache size is a setting or something that we have turned on--knowing Oracle, it might be a setting.

As far as the updates, I haven't checked the git logs, but once James looks over and blesses the changes, it will allow StatementCacheSize(int) to be optional.

In the mean time, if your string version of your connection string isn't returning what you expect, perhaps there's an additional underlying problem?  I'm assuming, since you have ShowSql() turned on, that you can see the SQL in your unit tests/debug and those statements work as expected if you copy them into SQL Developer or SQL*Plus?

-dl

Froggymeister

unread,
Aug 13, 2009, 5:57:04 PM8/13/09
to fluent-n...@googlegroups.com
So I got it working. Yea!
I ended up using the connection below.

It turns out that the reason I wasn't getting the expected results was because there weren't any results in the table to return. How could that be? Simple; when I first ran the application, it proceeded to create tables in my schema with names identical to the class names. So while I still had the "CATEGORY" table in the schema, a new table with the name "Category" was created. It did that for all classes except where in the HasManyToMany relationships I had specified the "WithTableName" method.

I had to go back and remove all the new tables and reset the constraints back as it was. With the mapping classes I specified the table names with the "WithTable" method. It all worked after that.

I am a newbie when it comes to NHibernate and Fluent NHibernate, so I will have to do some more reading to figure out why the new tables were created. How would I stop this from happening in cases where I already have a database with tables? I'd also have to learn about Oracle's case-sensitve object naming bit. Why and Why? I will also try and figure out the statement cache size setting for the Oracle DB.

===========================================
            var cfg = OracleClientConfiguration.Oracle9
                .ConnectionString( c => c

                    .Is( "DATA SOURCE=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.0.112)(PORT=1521))(CONNECT_DATA=(SERVER = DEDICATED)(SERVICE_NAME=XXX)));PERSIST SECURITY INFO=True;USER ID=XXXUser;Password=XXXUser" ) );

            return Fluently.Configure()
                    .Database( cfg )

                    .Mappings( m => m
                        .FluentMappings.AddFromAssemblyOf<Category>() )
                    .BuildSessionFactory();
===========================================



2009/8/14 David R. Longnecker <tireds...@gmail.com>

David R. Longnecker

unread,
Aug 14, 2009, 12:15:20 AM8/14/09
to fluent-n...@googlegroups.com
Glad you got it working!  If I may ask, when the changes hit the master branch, please give the Fluently method another shot... I'd be interested to see how things work out with the updates.

Thanks for the response! :)

-dl

Froggymeister

unread,
Aug 14, 2009, 2:03:21 AM8/14/09
to fluent-n...@googlegroups.com
I'll definitely give it a go when it's ready and available.
Reply all
Reply to author
Forward
0 new messages