Java Mailing List Archive

http://www.gg3721.com/

Home » the NHibernate development list »

Re: [NHibernate-development] NH-1098

Karl Chu

2008-02-25

Replies: Find Java Web Hosting

Author LoginPost Reply
Hi Wolfgang,

Please attach the tests and patch to NH-1098.  I would suggest not worrying too much about mixing of positional and named parameters.  However, the patch needs to work for the cases where either all positional or all named parameters are used.  Thanks.

Karl

PS: JIRA is temporarily located here: http://www.covalentsw.com:8080

On Mon, Feb 25, 2008 at 10:01 AM, Wolfgang Trog (CodeRunners AG) <wolfgang.trog@coderunners.ch> wrote:

Should I submit the fix anyway ? At least it solves the problem in a few defined cases ?

 

Regards,

Wolfgang

 

P.S: Do you need a fix for the trunk, 1.2.1 or both ?

 

From: nhibernate-development-bounces@lists.sourceforge.net [mailto:nhibernate-development-bounces@lists.sourceforge.net] On Behalf Of Wolfgang Trog (CodeRunners AG)
Sent: Dienstag, 19. Februar 2008 15:35


To: 'the NHibernate development list'
Subject: Re: [NHibernate-development] NH-1098

 

After writing some more test cases I figured out, that my fix does not work under all circumstances. The main problem seems to be that there are some assumption about the order of the parameter types (filter, named, positional) which are not correct if a subquery is used. My fix would solve the problem for criteria and queries without named parameters, but would still fail if one or more named parameters are used.

 

After some more analysis, I found out, that even a simple query won't work, if you mix named and positional parameters:

 

IQuery query = session.CreateQuery( "from A as a where a.ValueA > :ValA and a.ValueA < ?" );

            query.SetParameter( "ValA", 5 );

            query.SetInt32( 0, 7 );

 

NHibernate: select … where (a0_.val_a>@p0 )and(a0_.val_a<@p1 ); @p0 = '7', @p1 = '5'

 

@p0 and @p1 contain the wrong values. Sure, it not really reasonable to mix positional and named parameters in a query, but on the other hand I can't remember any constraint on that.

 

I tested all this on 1.2.1-GA, but I also had a quick look at the trunk and there seem to be no difference in handling the parameters.

 

Regards,

Wolfgang

 

 

 

From: nhibernate-development-bounces@lists.sourceforge.net [mailto:nhibernate-development-bounces@lists.sourceforge.net] On Behalf Of Ayende Rahien
Sent: Montag, 18. Februar 2008 07:16
To: the NHibernate development list
Subject: Re: [NHibernate-development] NH-1098

 

Can you submit a patch + test case for this?

On 2/6/08, Wolli <wolfgang@wollinet.com> wrote:

Hi All,

 

I ran into a problem with subqueries and filters, where the order of the parameters (positional and filter parameters, not named parameters) got messed up. I searched through the forum and JIRA and found to similar issues:

 

1)      NH-1098 (I'm not sure, if it's exactly the same problem, but pretty much sounds like it)

2)      http://forum.hibernate.org/viewtopic.php?t=971270

 

After some debugging I think I found the problem in method ProcessFilters in  QueryParameters (line 369 ff.). There, the SQL parts of the statement are analyzed and the parameters are added to the SQL string. During the loop the parameters (positional and filter) are added in the order they occur in the parts list, but only the filter parameters are added to the parameter list. After processing the parts, the positional parameters are added at the end of the parameter list, which may result in a wrong order.

 

I worked out a fix for the problem, but I'm not sure, if it does not cause other problems and would appreciate it if somebody could have a look on it. I can provide the fix and a test case. Should I open a new JIRA issue or should I upload the information to NH-1098 ?

 

Best Regards,

Wolfgang

 

               

 

 


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Nhibernate-development mailing list
Nhibernate-development@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nhibernate-development

 


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Nhibernate-development mailing list
Nhibernate-development@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nhibernate-development


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Nhibernate-development mailing list
Nhibernate-development@(protected)
https://lists.sourceforge.net/lists/listinfo/nhibernate-development
©2008 gg3721.com - Jax Systems, LLC, U.S.A.