Skip to content

NH-2634 - wrong select-query with many-to-one + cpmpositeId + pagination #1086

Open
@nhibernate-bot

Description

@nhibernate-bot

kirill.medvedev created an issue — 8th April 2011, 0:56:58:

While transferring legacy project to NHibernate I found a bug... Nhibernate generates wrong SELECT query => GenericADOException occurs. See attachment. Thank you.


kirill.medvedev added a comment — 8th April 2011, 1:44:08:

I've checked another ways to retrieve data. Criteria API and HQL behave the same way, as QueryOver, and cause an exception.

IList items = session.QueryOver().Skip(1).Take(20).List();

IList items = session.CreateCriteria().SetFirstResult(1).SetMaxResults(20).List();

IList items = session.CreateQuery("from Item").SetFirstResult(1).SetMaxResults(20).List();


Fabio Maulo added a comment — 8th April 2011, 8:44:19:

It seems yo have a wrong mapping in a collection.
The key of the collection point only to a part of the composite id of the related entity.


kirill.medvedev added a comment — 11th April 2011, 1:09:06:

Thank you for advice, I've checked it. Removing all collections' mappings didn't make any affect, exception appeared as before. But after removing

query completed without exceptions. Therefore, problem is in this many-to-one mapping part.

The most strange is that query

session.QueryOver().Take(100).List();

generates correct TSQL query and results are correct too. DefaultItemSupplier property is initialized as expected. But if I add Skip() restriction, exception occurs.

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