Skip to content

Entity with field interceptor are not correctly passed as Linq parameters #2514

Closed
@cremor

Description

@cremor

I've just updated from NHibernate 5.2.7 to 5.3.2 and now a few of my tests are failing. Some of them all have the same error where Oracle reports inconsistent datatypes for a parameter.

It looks like the affected Linq queries all pass the entities directly as a parameter, so NHibernate is responsible for extracting the Id from the object. This doesn't work any more in 5.3.x when the entity parameter type is XyzProxyForFieldInterceptor (which I think is the case if an entity with a lazy property or lazy component is loaded).

Example query:

// Person is mapped with a lazy component
Person personParameter = session.Get<Person>(123);

// Fails with Oracle error "inconsistent datatypes"
var result = Query<Customer>()
   .Where(x => x.Persons.Contains(personParameter))
   .ToArray();

The exception message contains the information Name:p1 - Value:{PersonProxyForFieldInterceptor}.
The SQL log output confirms the wrong parameter by showing something like this: :p0 = 0x0001000000FF... [Type: Object (0:0:0)]

If I change the query so that a just persisted object is used as a parameter (which isn't of type PersonProxyForFieldInterceptor but instead just of type Person) the query works correctly.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions