Samir, I think what Kevin meant is to use jOOQ's generated classes, but to
implement a VisitListener that works for all sorts of tables, not just the
hard-wired ACCOUNTS (and TRANSACTIONS) tables as mentioned in the blog post.
Kevin, this is certainly possible. Check out the logic inside of
pushConditions():
<E> void pushConditions(
VisitContext context,
Table<?> table,
Field<E> field,
E... values) {
// Check if we're visiting the given table
if (context.queryPart() == table) {
List<Clause> clauses = clauses(context);
In your case, instead of accepting a table and field parameter, the method
should probably accept a String for the field name, and then check if we're
visiting any table that contains the field name:
<E> void pushConditions(
VisitContext context,
String name,
E... values) {
// Check if we're visiting a table containing the field name
if (context.queryPart() instanceof Table && ((Table<?>)
context.queryPart()).field(name) != null) {
// ...
Beware that VisitListener logic must be implemented in a very performance
sensitive way. The above usage of the field(String) method might not
perform well enough, but it might give you an idea of where you need to go.
Let me know if this helps, and if you have any specific questions, I'll be
very happy to assist you.
Best Regards,
Lukas
2017-04-08 19:00 GMT+02:00 Samir Faci <[email protected]>:
> Well, how would you imagine that working in raw SQL. If you don't include
> the table name and you have more the one column with the same name you'll
> get an ambiguous error.
>
> Jooq is an abstraction of your DB and I'm trying to see how you'd build
> this query you're trying to write in Jooq.
>
>
>
> On Sat, Apr 8, 2017 at 8:24 AM, Kevin Embree <[email protected]>
> wrote:
>
>> I have been following the example given in blog post.
>> https://blog.jooq.org/2015/06/17/implementing-client-side-ro
>> w-level-security-with-jooq/
>>
>> In this example it pushes a condition if a specific column on a specific
>> table is present in the query.
>>
>> pushConditions(context, ACCOUNTS,
>> ACCOUNTS.ID, ids);
>>
>> I'm looking to push a condition for a column with a specific name on ANY
>> table that has that column present. I'm having trouble figuring out how to
>> identify/grab/return the Field of interest to push it into the condition.
>> Any help you can provide would be greatly apprecitated.
>>
>> Many thanks,
>> -Kevin
>>
>> --
>> 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.
>>
>
>
>
> --
> Thank you
> Samir Faci
> https://keybase.io/csgeek
>
> --
> 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.