I'm not really sure what's gone wrong, but I'll take a guess - maybe your dialect isn't being correctly read from your config file. Try specifying it via the fluent interface. See the wiki for examples.
You might want to try grabbing the latest code, and building and running the Examples.FirstProject. Then change the config to point at your sql 2008 database, and change the code in BuildSessionFactory accordingly. If you can get that to work, then you should be able to gradually change it to match your existing code and see where it breaks. Paul. On Wed, Dec 29, 2010 at 12:33 PM, apensado <[email protected]> wrote: > FluentNHibernate community, > > I am new the Hibernate and Fluent Hibernate world, and I am trying to > explore and understand the benefits of these ideas. However, I am > having troubles to make it work with a MS SQL 2008 database, and got > to the point that I need help. Hopefully someone in the community can > guide me. Here is the issue. > > I followed the example posted in > http://wiki.fluentnhibernate.org/Getting_started > but connecting to an MS SQL 2008 database, in a server. I must explain > that in the effort to solve the riddle, I have simplified the provided > example, reducing all to one table (Store) with Id and Name fields. > > Running the example, I stubble into an error when the program is > trying to commit the transaction. Allow me to present the error I get > in the log file (log4net): > > DEBUG 8 NHibernate.SQL - Batch commands: > command 0:UPDATE [Store] SET Name = @p0 WHERE Id = @p1;@p0 = 'Bargin > Basin', @p1 = 1 > command 1:UPDATE [Store] SET Name = @p0 WHERE Id = @p1;@p0 = > 'SuperMart', @p1 = 2 > DEBUG 8 NHibernate.AdoNet.AbstractBatcher - Closed IDbCommand, open > IDbCommands: 0 > ERROR 8 NHibernate.Event.Default.AbstractFlushingEventListener - Could > not synchronize database state with session > NHibernate.StaleStateException: Batch update returned unexpected row > count from update; actual row count: 0; expected: 2 > > I have set the configuration in a file, using the following construct > to load it > > var cfg = new Configuration(); > cfg.Configure(); // read config default style > ISessionFactory sessionFactory = > Fluently.Configure(cfg) > .Mappings(m => > m.FluentMappings.AddFromAssemblyOf<Program>() > .ExportTo(@"C:\tmp\NHibernateMappings")) > .BuildSessionFactory(); > > The configuration file( hibernate.cfg.xml) is as follows > > <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" > > <session-factory name="NHibernate.Test"> > <property > name="connection.driver_class">NHibernate.Driver.SqlClientDriver</ > property> > <property name="connection.connection_string"> > Data Source=IO\IOSQLSERVER;Initial Catalog=TestDb;Integrated > Security=True > </property> > <property name="adonet.batch_size">10</property> > <property name="show_sql">true</property> > <property > name="dialect">NHibernate.Dialect.MsSql2008Dialect</ > property> > <property name="use_outer_join">true</property> > <property name="command_timeout">60</property> > <property name="query.substitutions">true 1, false 0, yes > 'Y', no > 'N'</property> > <property > > name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, > NHibernate.ByteCode.Castle</property> > </session-factory> > </hibernate-configuration> > > The error suggests that the program was unable to update the database. > I have tried different approaches with no success. I have tried using > NHibernate.Dialect.MsSql2000Dialect and > NHibernate.Dialect.MsSql2008Dialect. I made several variations the > configuration unsuccessfully. > > It occurred to me and I copied the SQL commands indicated in the log > file into the SQL Server Management Studio, but the SQL constructs are > missing something or are not compatible. Here is the isolated SQL > command and error message, > > UPDATE [Store] > SET Name = @p0 WHERE Id = @p1;@p0 = 'Bargin Basin', @p1 = 1 > > Msg 137, Level 15, State 2, Line 1 > Must declare the scalar variable "@p0". > > I have “googled” for a solution without success, I have the impression > that It might be that I am not using the proper assemblies or the > configuration could be wrong. At this point I am hoping that someone > in the community can give me a hand to go over this hurdle. > > Thank you before hand for your assitance > > Armando Pensado > > -- > You received this message because you are subscribed to the Google Groups > "Fluent NHibernate" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<fluent-nhibernate%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/fluent-nhibernate?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Fluent NHibernate" 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/fluent-nhibernate?hl=en.
