-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Insert and Update with Oracle fails
PostPosted: Tue Jul 14, 2009 8:54 am 
Newbie

Joined: Fri Jul 10, 2009 1:05 am
Posts: 3
Hi,

Post Update: I have tracked down the problem at the command "ExecuteNonQuery". That's the one that fails during an update or hangs during an insert. Trying a simple example using plain ADO.NET and their transactions works perfect. Also... it works great on my local home computer connection an Oracle Express edition. Pointing it again in some kind of server config??

I've been scratching my head on this for a while now. I've been developing with NHibernate and an Oracle 10g database for a few days now, so far only using select statements which are all working great with the mapping.

I now started to implement my first insert (save) and update statements, but the tests all fail.
They all fail on the transaction.commit() part.

When performing an INSERT(Save), the code reaches transaction.commit(), but then got "stucked". The test keeps on running without moving forward.
This is the output of the test (note that the test keeps running)
Code:
NHibernate: select hibernate_sequence.nextval from dual
NHibernate: INSERT INTO MOB_PL_MAPPING_TEST (DES, TEST_ID) VALUES (:p0, :p1);:p0 = 'This is a test!', :p1 = 161


When performing an UPDATE, the transaction.commit() fails and I receive following error stack:
Code:
NHibernate: SELECT test0_.TEST_ID as TEST1_10_0_, test0_.DES as DES10_0_ FROM MOB_PL_MAPPING_TEST test0_ WHERE test0_.TEST_ID=:p0;:p0 = 61
NHibernate: UPDATE MOB_PL_MAPPING_TEST SET DES = :p0 WHERE TEST_ID = :p1;:p0 = 'Changed!', :p1 = 61
TestCase 'Data.Tests.Test_Update_on_Test_Table'
failed: NHibernate.TransactionException : Rollback failed with SQL Exception
  ----> System.InvalidOperationException : This OracleTransaction has completed; it is no longer usable.
   c:\CSharp\NH\nhibernate\src\NHibernate\Transaction\AdoTransaction.cs(260,0): at NHibernate.Transaction.AdoTransaction.Rollback()
   E:\SubVersion\Application\Src\Data\UnitOfWork\Data.UnitOfWork\GenericTransaction.cs(26,0): at Data.UOW.GenericTransaction.Rollback()
   E:\SubVersion\Application\Src\Data\UnitOfWork\Data.UnitOfWork\UnitOfWorkImplementor.cs(49,0): at Data.UOW.UnitOfWorkImplementor.TransactionFlush(IsolationLevel isolationLevel)
   E:\SubVersion\Application\Src\Data\UnitOfWork\Data.UnitOfWork\UnitOfWorkImplementor.cs(36,0): at Data.UOW.UnitOfWorkImplementor.TransactionFlush()
   E:\SubVersion\Application\Src\Data\Data.Tests\Repositories\LoyaltyRepositoryTests.cs(159,0): at Data.Tests.Test_Update_on_Test_Table()
   --InvalidOperationException
   at System.Data.OracleClient.OracleTransaction.AssertNotCompleted()
   at System.Data.OracleClient.OracleTransaction.Rollback()
   c:\CSharp\NH\nhibernate\src\NHibernate\Transaction\AdoTransaction.cs(246,0): at NHibernate.Transaction.AdoTransaction.Rollback()


I must say I'm unknown to oracle, but it seems that establishing the transaction causes the problem. Though the same code (using transactions) for a select statement (GET) works fine.
Could this be an oracle config problem (blocking insert/update transactions) or do I have to configure something else at application level?

Can anybody help me out here or shed more light on the problem that may occure?

Thanks in advance.


Top
 Profile  
 
 Post subject: Re: Insert and Update with Oracle fails
PostPosted: Wed Jul 15, 2009 9:42 am 
Newbie

Joined: Fri Jul 10, 2009 1:05 am
Posts: 3
After quite a while and some debugging into the NHibernate code, I found the problem (and the solution).
The problem was cause by the DbType of the string parameters. They where set to "String" and should have been "AnsiString".

The solution was to specify in the mapping for each string property the type "AnsiString".

Can't believe I spend so much time on this... :D


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.