Hi,

I've used NHibernate for a while now and I think it's great. However, I've 
run into some trouble in a recent scenario where I need to connect to an 
oracle database via ODBC. I can read data from the database just fine, but 
I get a rather undescriptive error message when I try to insert:

    NHibernate.Exceptions.GenericADOException: could not insert: 
[Domain.Phoenix.StructureAssign#35159][SQL: INSERT INTO STRUCTURE_ASSIGN 
(CLIENT_ID, STRUCTURE, NAME_CODE, START_DATE, FINISH_DATE, MEMO_NUMBER, 
ALTERNATE, ALTERNATE_NAME_CODE, ADMIN_NAME, AUDIT_NAME, VALID_DATE, 
AUDIT_ACTION, DIRECTOR_CLASS, STAT_SEQ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 
?, ?, ?, ?, ?)] ---> System.Data.Odbc.OdbcException
       at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, 
RetCode retcode)
       at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior 
behavior, String method, Boolean needReader, Object[] methodArguments, 
SQL_API odbcApiMethod)
       at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior 
behavior, String method, Boolean needReader)
       at System.Data.Odbc.OdbcCommand.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)
       --- End of inner exception stack trace ---
       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.Impl.StatelessSessionImpl.Insert(String entityName, 
Object entity)
       at NHibernate.Impl.StatelessSessionImpl.Insert(Object entity)
       at Domain.Repositories.StatelessRepository.Add[T](T model) in 
c:\Users\Owner\Dev\\Domain\Repositories\StatelessRepository.cs:line 112
       at PatchImport.Program.InsertBeneficiaries() in 
c:\Users\Owner\Dev\PatchImport\Program.cs:line 232
       at PatchImport.Program.Main(String[] args) in 
c:\Users\Owner\Dev\PatchImport\Program.cs:line 60

The insert works just fine if I connect to oracle directly rather than 
using ODBC.

Do you have any ideas what the cause might be? I wonder if it is due to the 
VALUES being all '?' rather than named parameters (p0,p1,p2, etc...).

I written about the problem in more detail on stackoverflow, but I think 
its a little too indepth and specific for that site! 
http://stackoverflow.com/questions/16240544/nhibernate-with-odbc-genericadoexception-could-not-insert

Any suggestions on how to resolve or work around this issue would be 
appreciated. Right now, I'm going to try manually writing 
Session.CreateSqlQuery("INSERT INTO .....") , but obviously this isn't an 
ideal solution!

Many thanks,
Oliver.

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to