From: "Hardy Ferentschik" <hardy(a)hibernate.org>
To: "Hibernate" <hibernate-dev(a)lists.jboss.org>
Sent: Friday, February 3, 2012 7:44:48 AM
Subject: Re: [hibernate-dev] deprecate positional parameters?
+1 for deprecating the HQL style positional parameters in this case.
On Feb 3, 2012, at 4:31 PM, Steve Ebersole wrote:
> The "force" is really 2 fold.
> First, yes there is problems when the resulting SQL query needs to
> be re-ordered for various reasons. The positional parameters
> sometimes end up in different orders from what they started. I
> *think* all those issues have been resolved now. The problem was
> that the code originally just assumed the position in the HQL and
> the position in the SQL would be the same in terms of order. IIRC
> I had to (1) separate the notions of positional parameter order
> and the positions they ended up in the SQL and then (2) add
> tracking between the 2 notions. So extra overhead there.
>
> Also, its confusing imo with the JPA notion of positional
> parameters. If the query uses jpa-style positional parameters,
> they have to be treated as named parameters in terms of binding to
> the org.hibernate.Query API. Our impl of javax.persistence.Query
> hides that complexity. But there is a mismatch between how those
> parameters are handled in the two APIs. Just so we are all clear
> on what this means...
>
> // HQL positional parameters:
> Query q = session.createQuery( "from Cat c where c.name = ?" )
> .setParameter( 1, "Tabitha" )
> ...
>
> // JPQL style:
> Query q = em.createQuery( "from Cat c where c.name = ?1" )
> .setParameter( 1, "Tabitha" )
> ...
>
> JPQL style, from Hibernate API:
> Query q = em.createQuery( "from Cat c where c.name = ?1" )
> .setParameter( "1", "Tabitha" )
> ...
>
>
> On Fri 03 Feb 2012 07:18:49 AM CST, Hardy Ferentschik wrote:
>> And just use named parameters?
>>
>> query.setString("name", "Fritz");
>>
>> I don't think have a strong opinion on that. I am fine w/
>> deprecating it.
>> What is the driving force behind? I recall that there were some
>> Jira issues which
>> had some issues with positional parameters. Are they related?
>>
>> --Hardy
>>
>>
>> On Feb 3, 2012, at 1:47 PM, Steve Ebersole wrote:
>>
>>> What do y'all think about deprecating positional parameters in
>>> HQL? I
>>> am talking about the HQL-specific notion here, not the JPA notion
>>> of a
>>> positional parameter which we obviously have to continue to
>>> support.
>>>
>>> HQL positional params are in the form:
>>> from Cat c where c.name = ?
>>>
>>> w/ setParameter(1, "steve")
>>>
>>> --
>>> steve(a)hibernate.org
>>>
http://hibernate.org
>>> _______________________________________________
>>> hibernate-dev mailing list
>>> hibernate-dev(a)lists.jboss.org
>>>
https://lists.jboss.org/mailman/listinfo/hibernate-dev
>>
>
> --
> steve(a)hibernate.org
>
http://hibernate.org
_______________________________________________
hibernate-dev mailing list
hibernate-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev