Re: [hibernate-dev] Continue "parameter list" support?

2016-09-11 Thread Steve Ebersole
The direction I went for now was to push collection of the parameters to
SQM itself and expose that from SqmStatement#getQueryParameters.
Additionally I have SQM validate the positional parameters per JPA spec
(1-based, contiguous).

I added org.hibernate.sqm.query.Parameter#allowsMultiValuedBinding which
gets set based on the parameters context.  We can leverage that in ORM.
The one caveat to that is the function stuff because atm SQM has no "object
view" of a function (SQLFunction or otherwise) so it has no idea if a
function allows "varargs"... we will have to either:

   1. validate that on the ORM side
   2. provide some "object view" of a function to SQM (via ConsumerContext)
   to check that.

(2) is nice because it would also allow us to understand the result-type of
a function also.


On Sat, Sep 10, 2016 at 10:02 AM Steve Ebersole  wrote:

> BTW... the question is not necessarily whether that parameter *is*
> multi-valued.  The question is whether it *can be* multi-valued.
>
> So from the initial SQM build we'd understand that a particular parameter
> is used in a way that indicated that its binding might be multi-valued.
> When we resolve that to a SQLFunction, e.g., we'd be able to ask the
> SQLFunction if it accepts varargs and:
>
> if ( sqmFunctionArgumentParameter.allowsMultiValues() ) {
> if ( !sqlFunction.acceptsVarargs() ) {
> log.debug( "SQLFunction [%s] does not accept varargs, adjusting
> SqmParameterExpression [%s] used as argument to not allow multi-values, ..
> );
> sqmFunctionArgumentParameter.allowMultiValues( false );
> }
> }
>
> On Sat, Sep 10, 2016 at 9:53 AM Steve Ebersole 
> wrote:
>
>> We are actually getting close to being able to wholly determine FUNCTION
>> syntactically.  So adding support for "collection valued input
>> parameters" as function arg should be pretty straight forward.
>>
>> And validation-wise I think it still works out nicely.  Basically that
>> leaves us 3 conditions:
>>
>>1. "collection valued input parameters" as IN expression value -
>>supported by HQL and JPQL
>>2. "collection valued input parameters" as (final) function argument
>>- supported by HQL but not JPQL strictly
>>3. "collection valued input parameters" anywhere else - not supported
>>in HQL or JPQL
>>
>>
>>
>>
>> On Sat, Sep 10, 2016 at 9:43 AM Christian Beikov <
>> christian.bei...@gmail.com> wrote:
>>
>>> My idea was to allow a parameter to be a collection valued parameter
>>> only in two cases
>>>
>>>  1. When used with the IN predicate
>>>  2. When used as last argument for a function and the parameter is a
>>> var-arg parameter
>>>
>>> That way the query can be validated upfront when knowing the registered
>>> functions and their argument types, but it's obviously not clear from
>>> just looking at the query string if a parameter is multi-valued or not.
>>> If you want to make the semantics independent of the functions, then you
>>> must introduce a syntax of course. I was just trying to suggest
>>> something that is mostly compatible to the way it is right now.
>>>
>>> Am 10.09.2016 um 16:10 schrieb Steve Ebersole:
>>> > WRT the "double caches"... yes there will be a few caches.
>>> >
>>> > I'm not understanding what that has to do with defining a clear
>>> > semantic for a particular language element.
>>> >
>>> > 
>>> >
>>> > Look, to me this whole thing boils down to the fact that JPA defines
>>> > specific/limited support for this "collection valued input parameter"
>>> > language element.  It does that btw because the ideal in language
>>> > design is to be able to wholly understand the semantic of a part of a
>>> > query based only on the syntax[1]. Further, JPA requires that we
>>> > handle a user binding a "collection valued input parameter" directly
>>> > through #setParameter.
>>> >
>>> > So all told we have a set of overloaded methods (#setParameterList)
>>> > that are not really providing any value[2], but that are needed
>>> > because that provides the only indication we ever get that a
>>> > particular parameter placeholder identifies a "collection valued input
>>> > parameter" rather than a"single valued input parameter". For all the
>>> > reasons discussed[1], thats not the ideal language design because it
>>> > is not deterministic from the grammar.
>>> >
>>> > Think of it this way...  It would be nice++ to be able to say "this
>>> > parameter is allowing multi-valued input" or "this parameter is
>>> > expecting single-valued input (multi-value input disallowed)", right?
>>> > Its the whole reason JPA defines its grammar (BNF) the way it does, so
>>> > that we can properly validate the incoming parameter input.  Today I
>>> > can do something like this:
>>> >
>>> > s.createQuery("from Zoo z where z.name  = :name" )
>>> >.setParameterList("name",new String[] {"San Antonio Zoo","Waco
>>> Zoo" } )
>>> >.list();
>>> > That is a completely "valid" query.  Its not going to return anything

[hibernate-dev] 6.0 - ResultTransformer

2016-09-11 Thread Steve Ebersole
Another legacy concept I'd like to revisit as we move to 6.0 is the
Hibernate ResultTransformer.  I'd argue that ResultTransformer is no longer
needed, especially in it's current form.

Specifically, ResultTransformer defines 2 distinct ways to transform the
results of a query:

   1. `#transformTuple` - this method operates on each "row" of the result,
   allowing the user to transform the Object[] into some other structure.
   This is specifically the one I see no value in moving forward.  Between
   dynamic-instantiation, Tuple-handling, etc I think users have the needed
   capabilities to transform the query result tuples.
   2. `#transformList` - this one operates on the query result as a whole
   (unless scroll/iterate are used).  This method at least adds something that
   cannot be done in another way.   But I'd still personally question its
   overall usefulness.

Does anyone have an argument for continuing to support either of these?
Personally, I propose just dropping the ResultTransformer support
altogether.
___
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev


[hibernate-dev] 6.0 - Session#createFilter

2016-09-11 Thread Steve Ebersole
Another method I'd like to drop is Session#createFilter.  This is method is
easy enough to replace with a call to createQuery instead.  Longer term I
can also see Stream or DSL support from our persistent collections to
provide the similar capabilities.  But for now its just no real benefit for
the cost of overly-complicating the grammars.
___
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev


Re: [hibernate-dev] 6.0 - ResultTransformer

2016-09-11 Thread Vlad Mihalcea
Hi,

We definitely need to address the ResultTranformer.
Only the former method is what we should be exposing, the latter being used
only in one particular use case, so that should be addressed by a different
contract.

This way we could provide a ResultTransformer using a lambda, which is not
possible today.

Vlad

On Mon, Sep 12, 2016 at 5:49 AM, Steve Ebersole  wrote:

> Another legacy concept I'd like to revisit as we move to 6.0 is the
> Hibernate ResultTransformer.  I'd argue that ResultTransformer is no longer
> needed, especially in it's current form.
>
> Specifically, ResultTransformer defines 2 distinct ways to transform the
> results of a query:
>
>1. `#transformTuple` - this method operates on each "row" of the result,
>allowing the user to transform the Object[] into some other structure.
>This is specifically the one I see no value in moving forward.  Between
>dynamic-instantiation, Tuple-handling, etc I think users have the needed
>capabilities to transform the query result tuples.
>2. `#transformList` - this one operates on the query result as a whole
>(unless scroll/iterate are used).  This method at least adds something
> that
>cannot be done in another way.   But I'd still personally question its
>overall usefulness.
>
> Does anyone have an argument for continuing to support either of these?
> Personally, I propose just dropping the ResultTransformer support
> altogether.
> ___
> hibernate-dev mailing list
> hibernate-dev@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>
___
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev


Re: [hibernate-dev] 6.0 - Session#createFilter

2016-09-11 Thread Vlad Mihalcea
I agree. The createFilter can be moved to the Query, so we don't require
this to be in the Session interface.

I haven't seen many questions about this functionality, so I guess we
shouldn't worry to much about this change.

Vlad

On Mon, Sep 12, 2016 at 6:02 AM, Steve Ebersole  wrote:

> Another method I'd like to drop is Session#createFilter.  This is method is
> easy enough to replace with a call to createQuery instead.  Longer term I
> can also see Stream or DSL support from our persistent collections to
> provide the similar capabilities.  But for now its just no real benefit for
> the cost of overly-complicating the grammars.
> ___
> hibernate-dev mailing list
> hibernate-dev@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>
___
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev