-
Notifications
You must be signed in to change notification settings - Fork 931
Description
Onur Gumus created an issue — 5th March 2012, 17:51:39:
See - http://forum.hibernate.org/viewtopic.php?t=934731
When specifying custom sql for loading a collection a
QueryException
is thrown when the the parameter binding class has a composite key.As in the post above, commenting out the code in
AbstractQueryImpl.VerifyParameters
fixes the issue but breaksLegacy.FooBarTest.VerifyParameterPositionalMissing
. Does the use case for this test still exist?Hbm Example
<?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" assembly="Foo.Bar.Interfaces" namespace="Foo.Bar.Interfaces"> <class name="Item" table="Item"> <composite-id> <key-property name="SellerId" access="field.camelcase-underscore" column="SellerId" /> <key-property name="Id" access="nosetter.camelcase-underscore" column="Id" /> </composite-id> <many-to-one name="Seller" access="nosetter.camelcase-underscore" class="Seller" column="SellerId" insert="false" update="false" /> <bag name="Alternates" access="nosetter.camelcase-underscore" generic="true"> <key> <column name="SellerId" /> <column name="Id" /> </key> <one-to-many class="Item" /> <loader query-ref="GetAlternateItems" /> </bag> </class> <sql-query name="GetAlternateItems"> <load-collection alias="alternateItem" role="Item.Alternates" /> EXEC GetAlternateItems ?, ? </sql-query> </hibernate-mapping>Attached patch for fix if commenting out the code is determined to be the way to go.
Onur Gumus added a comment — 5th March 2012, 17:53:37:
Apperantly there is a regression here.
It fails with an exception like "Expected positional parameter count: "... at
// NHibernate.Impl.AbstractQueryImpl.VerifyParameters(bool reserveFirstParameter)
Onur Gumus added a comment — 5th March 2012, 17:54:23:
Oh and this is a clone of https://nhibernate.jira.com/browse/NH-753
Oskar Berggren added a comment — 9th October 2013, 6:49:57:
In what version have you discovered this problem?
Onur Gumus added a comment — 9th October 2013, 7:11:31:
I guess the latest version at that time. Gotta be 3.1 or 3.2
hailtondecastro added a comment — 22nd December 2015, 18:39:34:
I have submitted two pull requests:
I made a workaround for the problem until it is officially fixed in NHibernate. The workaround is "NH3079Workaround.zip" (includes tests and needs to be compiled). This workaround was made for NHibernate 3 and is based on replacing the "event listeners"
DefaultInitializeCollectionEventListener
andDefaultLoadEventListener
byInitializeCollectionNH3079EventListener
andLoadNH3079EventListener
respectively.Test results before and after the fix:
- TestResultmasteroriginal.xml
- TestResultmasterafterfix.xml
- TestResult3.4original.xml
- TestResult3.4afterfix.xml