Ok, that's a good point !

Concerning manipulating / replace query object from an ExecuteListener, 
could you give me an example please ?
Which methods we have to use ?

Thanks for your help.

Le lundi 29 septembre 2014 18:24:16 UTC+2, Lukas Eder a écrit :
>
> Yes, I agree that the VisitListener is not an easy SPI to implement.
>
> In jOOQ 4.0, we're going to drastically improve the jOOQ "model" API, i.e. 
> the API that is used to model the AST (as opposed to the DSL API). This 
> will allow you to manipulate queries much more easily.
>
> Note that you can also manipulate / replace Query objects from an 
> ExecuteListener. It's just that you won't be able to access the various 
> Query elements as easily as you'd like.
>
> Best,
> Lukas
>
> 2014-09-29 11:52 GMT+02:00 <[email protected] <javascript:>>:
>
>> Ok thanks for the precisions.
>>
>> I just want to give my opinions concerning VisitListener. it seems to be 
>> powerfull, in fact, we can do everything that we want but it needs many 
>> codes for doing something. 
>> For example, adding automatically the tenant id on every queries, it is a 
>> bit complex :
>> https://github.com/jOOQ/jOOQ/blob/af7a7c504c08fcd4ecb10c9ca4091a7cff930fb8/jOOQ-test/src/test/java/org/jooq/test/all/testcases/VisitListenerTests.java
>>
>> According to me,  it can be usefull to doing this into the 
>> ExecuteListener, for have something more simple like ebean framework : 
>> For example, if I want to add the tenant id :
>>
>> @Override
>>     public void preQuery(BeanQueryRequest<?> request) {
>>         Query query = request.getQuery();
>>         query.where().eq("tenantId",TenantContext.get().getTenantId());
>>     }
>>
>> it only needs some lines of codes, if jooq could do something like this, 
>> it would be perfect !
>>
>>
>> Le jeudi 25 septembre 2014 08:53:00 UTC+2, Lukas Eder a écrit :
>>>
>>> I've registered a feature request for this jOOQ 4.0 improvement, for the 
>>> record:
>>> https://github.com/jOOQ/jOOQ/issues/3654
>>>
>>> 2014-09-25 8:51 GMT+02:00 Lukas Eder <[email protected]>:
>>>
>>>> The conceptual difference is rather simple:
>>>>
>>>> - A QueryPart is a concrete object in the query's AST and can be 
>>>> replaced directly by another QueryPart.
>>>> - A clause is a more syntactic idea of something that groups several 
>>>> QueryParts. Clauses don't have formal equivalents in the AST.
>>>>
>>>> An example of a clause is SELECT_FROM. It clearly delimits the FROM 
>>>> clause within a SELECT statement. Having clauses in the VisitContext 
>>>> allows 
>>>> you to distinguish between the different locations where a Table QueryPart 
>>>> is referenced from, e.g. the FROM clause, or the SELECT clause (as part of 
>>>> a Field).
>>>>
>>>> Does this make sense?
>>>>
>>>> We might improve this situation in jOOQ 4.0 and model all "clauses" as 
>>>> proper QueryParts, removing the need for these synthetic objects.
>>>>
>>>> 2014-09-24 18:15 GMT+02:00 <[email protected]>:
>>>>
>>>> Hi Lukas,
>>>>>
>>>>> Ok, that's good !
>>>>> I am just starting using VisitListener, for the moment my code is 
>>>>> nearly the same as your test unit. 
>>>>>
>>>>> I have a more general question for my understanding about 
>>>>> VisitListener, what's the difference between visitStart and ClauseStart ? 
>>>>>
>>>>> Javadoc says that VisitStart is called just before visiting a 
>>>>> QueryPart and the other just before entering a Clause.
>>>>> A queryPart seems to have many clauses. Please, could you give me an 
>>>>> exemple ?
>>>>>
>>>>> Thanks for your help.
>>>>>
>>>>> Cheers
>>>>>
>>>>> Alex
>>>>>
>>>>> Le mercredi 24 septembre 2014 17:21:04 UTC+2, Lukas Eder a écrit :
>>>>>>
>>>>>> Hi Alex,
>>>>>>
>>>>>> Thanks for linking that. I keep forgetting that this test is part of 
>>>>>> the test suite :-) We should be moving that into a new downloadable 
>>>>>> example 
>>>>>> project, where this use-case and many more can be debugged through for 
>>>>>> better understanding.
>>>>>>
>>>>>> Again, thanks for your info and glad it worked out for you.
>>>>>>
>>>>>> If you have any further questions / issues with the VisitListener, 
>>>>>> let us know
>>>>>>
>>>>>> Cheers
>>>>>> Lukas
>>>>>>
>>>>>> 2014-09-24 17:07 GMT+02:00 <[email protected]>:
>>>>>>
>>>>>> Hi Lukas, 
>>>>>>>
>>>>>>> Yes, of course !
>>>>>>>
>>>>>>> My main need was to add automatically some fields into the where 
>>>>>>> clause (like multi tenant discriminator). 
>>>>>>>
>>>>>>> This unit test help me a lot. It is more complex than the 
>>>>>>> documentation example, but according to me, it is really more useful !
>>>>>>>
>>>>>>> https://github.com/jOOQ/jOOQ/blob/af7a7c504c08fcd4ecb10c9ca4091a
>>>>>>> 7cff930fb8/jOOQ-test/src/test/java/org/jooq/test/all/te
>>>>>>> stcases/VisitListenerTests.java
>>>>>>>
>>>>>>> Cheers,
>>>>>>>
>>>>>>> Alex
>>>>>>>
>>>>>>> Le mercredi 24 septembre 2014 16:59:18 UTC+2, Lukas Eder a écrit :
>>>>>>>>
>>>>>>>> Hi Alexandre,
>>>>>>>>
>>>>>>>> That's great! Would you mind showing us a little what you did? I 
>>>>>>>> think this could be very valuable for future visitors of this mailing 
>>>>>>>> list 
>>>>>>>> thread.
>>>>>>>>
>>>>>>>> Cheers,
>>>>>>>> Lukas
>>>>>>>>
>>>>>>>> 2014-09-24 16:29 GMT+02:00 <[email protected]>:
>>>>>>>>
>>>>>>>> Hello Lukas,
>>>>>>>>>
>>>>>>>>> OK, thanks for your answer, I have finally solved my problem with 
>>>>>>>>> Visitor SPI !
>>>>>>>>>
>>>>>>>>> Le mercredi 24 septembre 2014 15:49:55 UTC+2, Lukas Eder a écrit :
>>>>>>>>>>
>>>>>>>>>> Yes, ExecuteListener is good for hooking into the lifecycle of 
>>>>>>>>>> rendering the SQL string, passing it to a JDBC PreparedStatement, 
>>>>>>>>>> passing 
>>>>>>>>>> the bind values to the PreparedStatement, executing the statement 
>>>>>>>>>> and 
>>>>>>>>>> fetching the results - whereas VisitListener allows for more 
>>>>>>>>>> detailed 
>>>>>>>>>> interaction with the SQL rendering and bind variable extraction 
>>>>>>>>>> steps.
>>>>>>>>>>
>>>>>>>>>> 2014-09-24 10:57 GMT+02:00 <[email protected]>:
>>>>>>>>>>
>>>>>>>>>>> I have implemented an ExecuteListener but VisitListener permit 
>>>>>>>>>>> to do SQL transformation, I will check this one !
>>>>>>>>>>>
>>>>>>>>>>> Le mercredi 24 septembre 2014 10:27:24 UTC+2, 
>>>>>>>>>>> [email protected] a écrit :
>>>>>>>>>>>
>>>>>>>>>>>> Hello,
>>>>>>>>>>>>
>>>>>>>>>>>> I am evatuating your library for maybe use it in our new 
>>>>>>>>>>>> project.
>>>>>>>>>>>> I have implemented my own listener and I want to check somes 
>>>>>>>>>>>> conditions into the query (where clause). Or maybe add a condition 
>>>>>>>>>>>> to the 
>>>>>>>>>>>> query.
>>>>>>>>>>>>
>>>>>>>>>>>> Is there a way to access to the private attribute conditions 
>>>>>>>>>>>> into the query object ? It seems to be very interesting for doing 
>>>>>>>>>>>> this.
>>>>>>>>>>>>
>>>>>>>>>>>> The only solution I have found is to use 
>>>>>>>>>>>> ctx.query().getSQL(ParamType.INLINED) but it is more 
>>>>>>>>>>>> complicated to work with a String.
>>>>>>>>>>>>
>>>>>>>>>>>> Thanks for your help.
>>>>>>>>>>>>
>>>>>>>>>>>  -- 
>>>>>>>>>>> You received this message because you are subscribed to the 
>>>>>>>>>>> Google Groups "jOOQ User Group" group.
>>>>>>>>>>> To unsubscribe from this group and stop receiving emails from 
>>>>>>>>>>> it, send an email to [email protected].
>>>>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>  -- 
>>>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>>>> Groups "jOOQ User Group" group.
>>>>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>>>>> send an email to [email protected].
>>>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>>>
>>>>>>>>
>>>>>>>>  -- 
>>>>>>> You received this message because you are subscribed to the Google 
>>>>>>> Groups "jOOQ User Group" group.
>>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>>> send an email to [email protected].
>>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>>
>>>>>>
>>>>>>  -- 
>>>>> You received this message because you are subscribed to the Google 
>>>>> Groups "jOOQ User Group" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>>> an email to [email protected].
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>>
>>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "jOOQ User Group" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to