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/
>>> testcases/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].
For more options, visit https://groups.google.com/d/optout.

Reply via email to