views:

141

answers:

2

Basically, I wish to fetch a filtered set of objects from the database (Oracle 9.2) based on the id property of the object PsalertsEvent. The code being executed is:

Public Overloads Function GetAll(ByVal laterThan As Long, ByVal filteredPsalertsEvents     As IList) As IList Implements IPsalertsEventRepo.GetAll
        'Get all psalerts events with an ID greater then the specified laterThan parameter
        filteredPsalertsEvents = MyBase.NHibernateSession.CreateQuery("from PsalertsEvent p where p.id > " & laterThan).List
        Return filteredPsalertsEvents
End Function

NUnit generates the following text ouput:

* PsalertsIp.Tests.Data.PSALERTSEventRepoTests.CanGetUnprocessedPsalertsEvents

NHibernate: select max(psalertsev0_.Id) as col_0_0_ from ALARM_REPLAY_NEW psalertsev0_ NHibernate: select psalertsev0_.Id as Id0_, psalertsev0_.ALARM_SUBSTATION_NAME as ALARM2_0_, psalertsev0_.ALARM_BUSBAR_NUM as ALARM3_0_, psalertsev0_.ALARM_COMPONENT_ALIAS as ALARM4_0_, psalertsev0_.ALARM_NAME as ALARM5_0_, psalertsev0_.ALARM_TEXT as ALARM6_0_, psalertsev0_.ALARM_TIME as ALARM7_0_ from ALARM_REPLAY_NEW psalertsev0_ where psalertsev0_.Id>20118832 NHibernate: UPDATE ALARM_REPLAY_NEW SET ALARM_SUBSTATION_NAME = :p0, ALARM_BUSBAR_NUM = :p1, ALARM_COMPONENT_ALIAS = :p2, ALARM_NAME = :p3, ALARM_TEXT = :p4, ALARM_TIME = :p5 WHERE Id = :p6;:p0 = 'Value Text', :p1 = 0, :p2 = 'Value Text', :p3 = NULL, :p4 = 'CLOSED', :p5 = 10/03/2010 15:06:31, :p6 = 20118833 15:06:56,389 ERROR [TestRunnerThread] AbstractBatcher [(null)]- Could not execute command: UPDATE ALARM_REPLAY_NEW SET ALARM_SUBSTATION_NAME = :p0, ALARM_BUSBAR_NUM = :p1, ALARM_COMPONENT_ALIAS = :p2, ALARM_NAME = :p3, ALARM_TEXT = :p4, ALARM_TIME = :p5 WHERE Id = :p6 Oracle.DataAccess.Client.OracleException ORA-01031: insufficient privileges at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src, String procedure)

at Oracle.DataAccess.Client.OracleException.HandleError(Int32 errCode, OracleConnection conn, String procedure, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src)

at Oracle.DataAccess.Client.OracleCommand.ExecuteNonQuery()

at NHibernate.AdoNet.AbstractBatcher.ExecuteNonQuery(IDbCommand cmd)

NUnit passes the test in question, however an error is subsequently generated centered on the oracle exception:

Oracle.DataAccess.Client.OracleException ORA-01031: insufficient privileges

+3  A: 

Without seeing your mapping it's impossible to give you a solid answer but the most likely answer is that you've ran into a problem called ghosting for which a little Ghost Busting is required.

While there are a few causes the most likely cause is that your PsalertsEvent has an enum which isn't being mapped properly via an IUserType.

ShaneC
+1 hmmm I map enums no problem by specifying the fully qualified name in the type property. For me, it's usually some combination of datetime and nulls that cause ghosting.
dotjoe
A: 

It's probably happening because one or more of the objects that would be returned by the query have changes that have not been persisted. NHibernate is trying to be helpful by ensuring that your in-memory objects are consistent. In order to do this, it has to update the database before executing the query. As previously mentioned, this can be caused by "ghosting" or explicit changes.

Jamie Ide