Creating the TransactionScope object within the NHibernate session (rather than the reverse) fixes my problem.
On Jan 22, 11:15 am, jprid64 <[email protected]> wrote: > Thanks, Diego. I tried the Informix driver and can now perform the > insert. Extending my test program, I am trying to wrap the insert > inside a distributed transaction using a TransactionScope object. If I > don't create the TransactionScope object with > EnterpriseServicesInteropOption.Full, the insert does not participate > in the transaction and so does not roll back when the TS object goes > out of scope without a .Complete() call. If I DO create it with that > option, I get a "Could not close IBM.Data.Informix.IfxConnection > connection" on my call to BuildSessionFactory(). Any suggestions? BTW, > if you think it would be better for me to start a new thread, I'd be > happy to. > > On Jan 22, 10:21 am, Diego Mijelshon <[email protected]> wrote: > > > Adding the column sizes to the mapping might help. > > However, you should be using the Informix driver. Here's a sample config: > > > <property > > name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property> > > > <property name="connection.connection_string">Host={informix host > > name};Service={informix "service" (port)};Server={informix > > instance};Database={database name};uid={user > > name};password={password}</property> > > <property name="dialect">NHibernate.Dialect.InformixDialect1000</property> > > > Diego > > > On Wed, Jan 20, 2010 at 14:59, jprid64 <[email protected]> wrote: > > > I am new to NHibernate (2.1.2) and am trying to get a working sample > > > going with our IDS-Express database (11.50) as proof of concept. I'm > > > currently using the OleDbDriver (Client-SDK 3.50.FC5 -- though I would > > > certainly be willing to use IfxDriver if I could get the configuration > > > right). > > > > Borrowing from the example in NHibernate in Action (dated, I know, as > > > it basically covers 1.2), I'm trying to do a simple insert into a > > > table with the following schema: > > > create table "johnp".employee > > > ( > > > id serial not null , > > > name varchar(50), > > > manager integer > > > ); > > > > Upon trying to save my object, I get the following error: > > > > {"While preparing INSERT INTO Employee (id, name, manager) VALUES > > > (0, ?, ?) an error occurred"} > > > "OleDbCommand.Prepare method requires all variable length parameters > > > to have an explicitly set non-zero Size." > > > > Here is my mapping file: > > > <?xml version="1.0" ?> > > > <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto- > > > import="true"> > > > <class name="HelloNHibernate.Employee, HelloNHibernate" > > > lazy="false"> > > > <id name="id" access="field"> > > > <generator class="identity" /> > > > </id> > > > <property name="name" access="field" column="name" /> > > > <many-to-one access="field" name="manager" column="manager" > > > cascade="all" /> > > > </class> > > > </hibernate-mapping> > > > > And here is the relevant portion of my App.Config: > > > <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> > > > <session-factory> > > > <property > > > > name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, > > > NHibernate.ByteCode.Castle</property> > > > <property > > > name="connection.provider">NHibernate.Connection.DriverConnectionProvider</ > > > property> > > > <property > > > name="connection.driver_class">NHibernate.Driver.OleDbDriver</ > > > property> > > > <property > > > name="connection.connection_string">Provider=Ifxoledbc.3;Data > > > source=hellonhibern...@dev_on;Persist Security > > > Info=True;Password=********;User ID=********</property> > > > <property > > > name="dialect">NHibernate.Dialect.InformixDialect</property> > > > <property name="show_sql">false</property> > > > </session-factory> > > > </hibernate-configuration> > > > > What do I need to change in my mapping/config to make this work? > > > > -- > > > 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]<nhusers%[email protected]> > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/nhusers?hl=en. > > -- 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.
