Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cremor opened this issue Sep 3, 2020 · 0 comments
Closed

Comments

@cremor
Copy link
Contributor

cremor commented Sep 3, 2020

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.

@fredericDelaporte fredericDelaporte added this to the 5.3.3 milestone Sep 6, 2020
@fredericDelaporte fredericDelaporte changed the title [5.3.x regression] Entity objects of type XyzProxyForFieldInterceptor are not correctly passed as parameters to Linq queries Entity with field interceptor are not correctly passed as Linq parameters Sep 6, 2020
@hazzik hazzik added the r: Fixed label Sep 9, 2020
@hazzik hazzik closed this as completed Sep 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants