Skip to content

NH-3902 - ORA-00904: "THIS_"."ID" when combining SetMaxResults and SetLockMode in single query #1352

Open
@nhibernate-bot

Description

@nhibernate-bot

bimcio created an issue — 24th August 2016, 9:43:37:

I have a simple table (let's call it MyTable) which I query as follows:

ICriteria query = session.CreateCriteria(typeof(MyTable))
	.SetMaxResults(1)
	.SetLockMode(LockMode.Upgrade); 

var list = query.List<MyTable>(); 

This fails on Oracle with following exception:

DataAccess.Client.OracleException ORA-00904: "THIS_"."ID": invalid identifier    

Generated SQL is (I obfuscated the query by removing the columsn which are not important for the example here):

select Id132_0_, /* more columns here */ KeyId132_0_ from 
( SELECT this_.Id as Id132_0_, /* more columns here */ this_.KeyId as KeyId132_0_ FROM MyTable this_ ) 
where rownum <=:p0 for update of this_.Id; :p0 = 1 <Type: Int32 (0)>

I think this problem might be somehow related to NH-111 / NH-1023, but defintelly can be observed in NH 4.0.4.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions