Hi, I am new to this community. I have successfully managed getting data from the database, but am still having problem to insert data into it. When I save data (see the code below), the NHibernate seems generates a parameterized insert statement (see below). And that “Commit” execution throws an exception (ORA-00928: missing SELECT keyword). When I copy and the paste the generated insert statement to the SQLPlus, I get the same error. But if I use the regular insert statement (with columns and values). It works fine. So, I am wondering is the NHibernate generating the correct insert statement for me. If it does not, did I miss any setting? During my debugging process, at a point I have to specify the assembly binding to Oracle.DataAccess in the runtime section of the configuration. Does this raise any warning?
Here is the related configuration
<runtime>
...
...
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<qualifyAssembly partialName="Oracle.DataAccess" fullName="Oracle.DataAccess, Version=10.1.0.200, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</assemblyBinding>
</runtime>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<bytecode-provider type="lcg"/>
<reflection-optimizer use="true"/>
<session-factory name="NHibernate.Default">
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.OracleDataClientDriver</property>
<property name="connection.connection_string">Data source=dummy;User Id=user;Password=pass;</property>
<property name="show_sql">true</property>
<!--<property name="dialect">NHibernate.Dialect.Oracle9Dialect</property>-->
<property name="dialect">NHibernate.Dialect.OracleDialect</property>
<property name="use_outer_join">true</property>
<property name="command_timeout">444</property>
<property name="query.substitutions">true 1, false 0, yes 'Y', no 'N'</property>
<property name="adonet.wrap_result_sets">false</property>
<mapping assembly="ProgressiveNhEdm"/>
</session-factory>
</hibernate-configuration>
Hibernate version:
2.0GA
Mapping documents:
<class name="Workflowindex" table="WORKFLOWINDEX" lazy="false">
<id name="Workflowindexid" column="WORKFLOWINDEXID" type="Decimal">
<generator class="assigned" />
</id>
<property type="string" length="50" name="Name" column="[NAME]" />
<property type="string" length="250" name="Description" column="[DESCRIPTION]" />
</class>
Code between sessionFactory.openSession() and session.close():
ITransaction tx = session.BeginTransaction();
Workflowindex wfi = new Workflowindex();
wfi.Workflowindexid = 2;
wfi.Name= "wfi2";
wfi.Description = "workflow index created from nhibernate";
session.Save(wfi);
tx.Commit();
Full stack trace of any exception that occurs:
Oracle.DataAccess.Client.OracleException was unhandled
Message="ORA-00928: missing SELECT keyword"
Source="Oracle Data Provider for .NET"
DataSource="utxprogorap01.tx.epsilon.com:1521/progd1"
Number=928
Procedure=""
StackTrace:
at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure)
at Oracle.DataAccess.Client.OracleCommand.ExecuteNonQuery()
at NHibernate.AdoNet.AbstractBatcher.ExecuteNonQuery(IDbCommand cmd)
at NHibernate.AdoNet.NonBatchingBatcher.AddToBatch(IExpectation expectation)
at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id, Object[] fields, Boolean[] notNull, Int32 j, SqlCommandInfo sql, Object obj, ISessionImplementor session)
at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object id, Object[] fields, Object obj, ISessionImplementor session)
at NHibernate.Action.EntityInsertAction.Execute()
at NHibernate.Engine.ActionQueue.Execute(IExecutable executable)
at NHibernate.Engine.ActionQueue.ExecuteActions(IList list)
at NHibernate.Engine.ActionQueue.ExecuteActions()
at NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource session)
at NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent event)
at NHibernate.Impl.SessionImpl.Flush()
at NHibernate.Transaction.AdoTransaction.Commit()
at SampleApp.Program.TestSave(ISession session) in C:\Dev\ProgressiveNhEdm2\SampleApp\Program.cs:line 54
at SampleApp.Program.Main(String[] args) in C:\Dev\ProgressiveNhEdm2\SampleApp\Program.cs:line 28
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
Name and version of the database you are using:
Oracle 10g
The generated SQL (show_sql=true):
INSERT INTO WORKFLOWINDEX ([NAME], [DESCRIPTION], WORKFLOWINDEXID) VALUES (:p0, :p1, :p2); :p0 = 'wfi2', :p1 = 'workflow index created from nhibernate', :p2 = '2'
Debug level Hibernate log excerpt:
NHibernate.Transaction.AdoTransaction: 2008-09-20 08:43:44,782 [10] DEBUG NHibernate.Transaction.AdoTransaction [(null)] - Start Commit
NHibernate.Event.Default.AbstractFlushingEventListener: 2008-09-20 08:43:44,782 [10] DEBUG NHibernate.Event.Default.AbstractFlushingEventListener [(null)] - flushing session
NHibernate.Event.Default.AbstractFlushingEventListener: 2008-09-20 08:43:44,782 [10] DEBUG NHibernate.Event.Default.AbstractFlushingEventListener [(null)] - processing flush-time cascades
NHibernate.Event.Default.AbstractFlushingEventListener: 2008-09-20 08:43:44,782 [10] DEBUG NHibernate.Event.Default.AbstractFlushingEventListener [(null)] - dirty checking collections
NHibernate.Event.Default.AbstractFlushingEventListener: 2008-09-20 08:43:44,782 [10] DEBUG NHibernate.Event.Default.AbstractFlushingEventListener [(null)] - Flushing entities and processing referenced collections
NHibernate.Event.Default.AbstractFlushingEventListener: 2008-09-20 08:43:44,798 [10] DEBUG NHibernate.Event.Default.AbstractFlushingEventListener [(null)] - Processing unreferenced collections
NHibernate.Event.Default.AbstractFlushingEventListener: 2008-09-20 08:43:44,798 [10] DEBUG NHibernate.Event.Default.AbstractFlushingEventListener [(null)] - Scheduling collection removes/(re)creates/updates
NHibernate.Event.Default.AbstractFlushingEventListener: 2008-09-20 08:43:44,798 [10] DEBUG NHibernate.Event.Default.AbstractFlushingEventListener [(null)] - Flushed: 1 insertions, 0 updates, 0 deletions to 1 objects
NHibernate.Event.Default.AbstractFlushingEventListener: 2008-09-20 08:43:44,798 [10] DEBUG NHibernate.Event.Default.AbstractFlushingEventListener [(null)] - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
NHibernate.Impl.Printer: 2008-09-20 08:43:44,798 [10] DEBUG NHibernate.Impl.Printer [(null)] - listing entities:
NHibernate.Impl.Printer: 2008-09-20 08:43:44,813 [10] DEBUG NHibernate.Impl.Printer [(null)] - ProgressiveNhEdm.Workflowindex{Name=wfi1, Workflowindexid=2, Description=workflow index created from nhibernate}
NHibernate.Event.Default.AbstractFlushingEventListener: 2008-09-20 08:43:44,813 [10] DEBUG NHibernate.Event.Default.AbstractFlushingEventListener [(null)] - executing flush
NHibernate.AdoNet.ConnectionManager: 2008-09-20 08:43:44,813 [10] DEBUG NHibernate.AdoNet.ConnectionManager [(null)] - registering flush begin
NHibernate.Persister.Entity.AbstractEntityPersister: 2008-09-20 08:43:44,813 [10] DEBUG NHibernate.Persister.Entity.AbstractEntityPersister [(null)] - Inserting entity: [ProgressiveNhEdm.Workflowindex#2]
NHibernate.AdoNet.AbstractBatcher: 2008-09-20 08:43:44,844 [10] DEBUG NHibernate.AdoNet.AbstractBatcher [(null)] - Opened new IDbCommand, open IDbCommands: 1
NHibernate.AdoNet.AbstractBatcher: 2008-09-20 08:43:44,844 [10] DEBUG NHibernate.AdoNet.AbstractBatcher [(null)] - Building an IDbCommand object for the SqlString: INSERT INTO WORKFLOWINDEX ([NAME], [DESCRIPTION], WORKFLOWINDEXID) VALUES (?, ?, ?)
NHibernate.Persister.Entity.AbstractEntityPersister: 2008-09-20 08:43:44,844 [10] DEBUG NHibernate.Persister.Entity.AbstractEntityPersister [(null)] - Dehydrating entity: [ProgressiveNhEdm.Workflowindex#2]
NHibernate.Type.StringType: 2008-09-20 08:43:44,844 [10] DEBUG NHibernate.Type.StringType [(null)] - binding 'wfi1' to parameter: 0
NHibernate.Type.StringType: 2008-09-20 08:43:44,844 [10] DEBUG NHibernate.Type.StringType [(null)] - binding 'workflow index created from nhibernate' to parameter: 1
NHibernate.Type.DecimalType: 2008-09-20 08:43:44,844 [10] DEBUG NHibernate.Type.DecimalType [(null)] - binding '2' to parameter: 2
NHibernate.SQL: 2008-09-20 08:43:44,844 [10] DEBUG NHibernate.SQL [(null)] - INSERT INTO WORKFLOWINDEX ([NAME], [DESCRIPTION], WORKFLOWINDEXID) VALUES (:p0, :p1, :p2); :p0 = 'wfi1', :p1 = 'workflow index created from nhibernate', :p2 = '2'
NHibernate.Transaction.AdoTransaction: 2008-09-20 08:43:44,860 [10] DEBUG NHibernate.Transaction.AdoTransaction [(null)] - Enlist Command
NHibernate.AdoNet.AbstractBatcher: 2008-09-20 08:43:45,157 [10] DEBUG NHibernate.AdoNet.AbstractBatcher [(null)] - Closed IDbCommand, open IDbCommands: 0
A first chance exception of type 'Oracle.DataAccess.Client.OracleException' occurred in NHibernate.dll
'SampleApp.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.DebuggerVisualizers\9.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.DebuggerVisualizers.dll'
NHibernate.AdoNet.ConnectionManager: 2008-09-20 08:43:47,157 [10] DEBUG NHibernate.AdoNet.ConnectionManager [(null)] - registering flush end
Problems with Session and transaction handling?
|