> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Max Rydahl Andersen
> Sent: Wednesday, December 22, 2004 3:00 PM
> To: Hibernate development
> Subject: Re: [Hibernate] new template-based hql functions
> 
> On Wed, 22 Dec 2004 06:40:21 -0600, Alexey  Loubyansky 
> <[EMAIL PROTECTED]>
> wrote:
> 
> > In general we might define a function like func(a, b, c) 
> and the order 
> > of arguments might be different in different dialects. (I 
> am not sure 
> > we need this though. This is how JBossCMP does it.) So just 
> '?' won't 
> > work.
> 
> oh - so you can define it as locate(?1, ?3, ?2) and when you 
> call it with locate(a,b,c) it would be transformed into
> locate(a,c,b) ?

Right.

> > :name is a bit more complex. How would you call a function 
> in case of 
> > using :name?
> 
> If the above is true, I would say locate(:1, :3, :2) would be 
> just as nice (even imagine dateconvert(:year, :month, :day, 
> :hour, :seconds)) which for me says much more.

Yes, it makes sense. Referencing parameters by name is always more
expensive though (from both performance and implementation point of
view).

> And if you support ?[0-9]+ syntax, then i guess the parsing 
> would be the same - just :[a-z]+ instead - or am i totally 
> offbeat here...

No, parsing is not a problem. This is parsed not by the query parser but
by the SQLFunctionTemplate class.

> but again - it's mostly the for me "unneedded" extra syntax i 
> would like to avoid...

Ok. Thanks.

> 
> /max
> 
> >
> >> -----Original Message-----
> >> From: [EMAIL PROTECTED]
> >> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Max 
> >> Rydahl Andersen
> >> Sent: Wednesday, December 22, 2004 1:23 PM
> >> To: Hibernate development
> >> Subject: Re: [Hibernate] new template-based hql functions
> >>
> >> On Wed, 22 Dec 2004 06:10:57 -0600, Alexey  Loubyansky 
> >> <[EMAIL PROTECTED]>
> >> wrote:
> >>
> >> Looks nice.
> >>
> >> Stupid question again from me - any reason why you use ?1 
> syntax and 
> >> not just ? or :name here ?
> >> (Just to keep the syntaxes for placeholders down at a minimum ,)
> >>
> >> /max
> >>
> >> > This is committed now.
> >> > To define a new function template you create an instance of 
> >> > SQLFunctionTemplate which implements SQLFunction and
> >> register it in a
> >> > dialect as any other SQLFunction, e.g.
> >> >
> >> >       registerFunction("locate", new 
> >> > SQLFunctionTemplate(Hibernate.INTEGER, "locate(?1, ?2, ?3)"));
> >> >
> >> > By the spec, this locate function might have 2 or 3 
> parameters. So, 
> >> > you define 3 in the template but can pass just 2.
> >> >
> >> > If the template is not found for a specific dialect when 
> generating 
> >> > SQL, the function will appear in the generated SQL as it 
> appears in 
> >> > the EJB/H-QL statement. I.e. it is how it worked before.
> >> >
> >> >> -----Original Message-----
> >> >> From: [EMAIL PROTECTED]
> >> >> [mailto:[EMAIL PROTECTED] On 
> Behalf Of 
> >> >> Alexey Loubyansky
> >> >> Sent: Wednesday, December 22, 2004 12:39 PM
> >> >> To: Max Andersen; Hibernate development
> >> >> Subject: RE: [Hibernate] new template-based hql functions
> >> >>
> >> >> > > concat(?1 || ?2) is parsed not as one argument but three,
> >> >> > since there
> >> >> > > are three tokens, i.e. ?1, || and ?2.
> >> >> >
> >> >> > oh - afraid of sounding stupid, but shouldn't that be 
> parsed as 
> >> >> > a
> >> >> > functioncall(expression) ?
> >> >> > where expression is (x op y) in this case ?
> >> >>
> >> >> Yes, sorry, of course, it is parsed like this.
> >> >> I had a bug in creating an argument list. It works now.
> >> >>
> >> >> Thanks.
> >> >>
> >> >>
> >> >> -------------------------------------------------------
> >> >> SF email is sponsored by - The IT Product Guide Read
> >> honest & candid
> >> >> reviews on hundreds of IT Products from real users.
> >> >> Discover which products truly live up to the hype. Start
> >> reading now.
> >> >> http://productguide.itmanagersjournal.com/
> >> >> _______________________________________________
> >> >> hibernate-devel mailing list
> >> >> hibernate-devel@lists.sourceforge.net
> >> >> https://lists.sourceforge.net/lists/listinfo/hibernate-devel
> >> >>
> >>
> >>
> >>
> >> --
> >> Max Rydahl Andersen
> >> callto://max.rydahl.andersen
> >>
> >> Hibernate
> >> [EMAIL PROTECTED]
> >> http://hibernate.org
> >>
> >> JBoss Inc
> >> [EMAIL PROTECTED]
> >> http://jboss.com
> >>
> >>
> >> -------------------------------------------------------
> >> SF email is sponsored by - The IT Product Guide Read 
> honest & candid 
> >> reviews on hundreds of IT Products from real users.
> >> Discover which products truly live up to the hype. Start 
> reading now.
> >> http://productguide.itmanagersjournal.com/
> >> _______________________________________________
> >> hibernate-devel mailing list
> >> hibernate-devel@lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/hibernate-devel
> >>
> 
> 
> 
> --
> Max Rydahl Andersen
> callto://max.rydahl.andersen
> 
> Hibernate
> [EMAIL PROTECTED]
> http://hibernate.org
> 
> JBoss Inc
> [EMAIL PROTECTED]
> http://jboss.com
> 
> 
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide Read honest & 
> candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now. 
> http://productguide.itmanagersjournal.com/
> _______________________________________________
> hibernate-devel mailing list
> hibernate-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/hibernate-devel
> 


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
hibernate-devel mailing list
hibernate-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hibernate-devel

Reply via email to