How do I wrap brackets around parameter values when using jOOq?










3














I am using jOOq to write queries except I am using a vendor specific type of SQL... to be specific flexible search. The main difference between SQL and flexiSearch is that parameter values are enclosed in a curly bracket. e.g.



SELECT * FROM Product WHERE code LIKE ‘%al%’


So what I'm trying to do is to get jOOq to automatically intercept the query building procedure to include the brackets.



Looking through the docs, it seems that I should implement some kind of execute listener? But I am not sure what to do after that. Thanks










share|improve this question























  • Also, you need to- 1. Put curly braces around tables and their joins. 2. Apply double curly braces around subquery. to ensure the queries format match.
    – Farrukh Chishti
    Nov 13 at 10:00















3














I am using jOOq to write queries except I am using a vendor specific type of SQL... to be specific flexible search. The main difference between SQL and flexiSearch is that parameter values are enclosed in a curly bracket. e.g.



SELECT * FROM Product WHERE code LIKE ‘%al%’


So what I'm trying to do is to get jOOq to automatically intercept the query building procedure to include the brackets.



Looking through the docs, it seems that I should implement some kind of execute listener? But I am not sure what to do after that. Thanks










share|improve this question























  • Also, you need to- 1. Put curly braces around tables and their joins. 2. Apply double curly braces around subquery. to ensure the queries format match.
    – Farrukh Chishti
    Nov 13 at 10:00













3












3








3







I am using jOOq to write queries except I am using a vendor specific type of SQL... to be specific flexible search. The main difference between SQL and flexiSearch is that parameter values are enclosed in a curly bracket. e.g.



SELECT * FROM Product WHERE code LIKE ‘%al%’


So what I'm trying to do is to get jOOq to automatically intercept the query building procedure to include the brackets.



Looking through the docs, it seems that I should implement some kind of execute listener? But I am not sure what to do after that. Thanks










share|improve this question















I am using jOOq to write queries except I am using a vendor specific type of SQL... to be specific flexible search. The main difference between SQL and flexiSearch is that parameter values are enclosed in a curly bracket. e.g.



SELECT * FROM Product WHERE code LIKE ‘%al%’


So what I'm trying to do is to get jOOq to automatically intercept the query building procedure to include the brackets.



Looking through the docs, it seems that I should implement some kind of execute listener? But I am not sure what to do after that. Thanks







java sql jooq hybris flexible-search






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 at 9:59









Lukas Eder

132k70429937




132k70429937










asked Nov 12 at 15:03









user1272052

263




263











  • Also, you need to- 1. Put curly braces around tables and their joins. 2. Apply double curly braces around subquery. to ensure the queries format match.
    – Farrukh Chishti
    Nov 13 at 10:00
















  • Also, you need to- 1. Put curly braces around tables and their joins. 2. Apply double curly braces around subquery. to ensure the queries format match.
    – Farrukh Chishti
    Nov 13 at 10:00















Also, you need to- 1. Put curly braces around tables and their joins. 2. Apply double curly braces around subquery. to ensure the queries format match.
– Farrukh Chishti
Nov 13 at 10:00




Also, you need to- 1. Put curly braces around tables and their joins. 2. Apply double curly braces around subquery. to ensure the queries format match.
– Farrukh Chishti
Nov 13 at 10:00












1 Answer
1






active

oldest

votes


















2














You could indeed implement an ExecuteListener that replaces



  • every odd " by a and every even " by a using any dialect (be careful of syntactic ambiguities)

  • every odd ` by a and every even ` by a using MySQL dialect

  • every [ by a and every ] by a using SQL Server dialect

But from what I can tell, that won't be the only thing you'll be patching in generated SQL, so you might as well fork the jOOQ Open Source Edition and patch the relevant code yourself.



Beware, jOOQ doesn't really support this particular dialect. This will not be the only thing you'll run into. For example, you could try to pattern match subqueries in an ExecuteListener and wrap them in ... , but that, too, would be much easier to achieve by patching jOOQ directly.






share|improve this answer






















  • Hi @Lukas, thanks for your reply, it was really insightful. I had a go at overriding DefaultVisitLister (I need to render the sql string) but I am struggling in getting to replace the quotes with brackets using render context. This is what I tried context.renderContext().render().replaceAll("[]","[");` but I get NullPointer
    – user1272052
    Nov 15 at 12:46











  • @user1272052: I'll be happy to answer new questions with examples, showing what you did and more info about the problem you're getting.
    – Lukas Eder
    Nov 16 at 8:08










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53264890%2fhow-do-i-wrap-brackets-around-parameter-values-when-using-jooq%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














You could indeed implement an ExecuteListener that replaces



  • every odd " by a and every even " by a using any dialect (be careful of syntactic ambiguities)

  • every odd ` by a and every even ` by a using MySQL dialect

  • every [ by a and every ] by a using SQL Server dialect

But from what I can tell, that won't be the only thing you'll be patching in generated SQL, so you might as well fork the jOOQ Open Source Edition and patch the relevant code yourself.



Beware, jOOQ doesn't really support this particular dialect. This will not be the only thing you'll run into. For example, you could try to pattern match subqueries in an ExecuteListener and wrap them in ... , but that, too, would be much easier to achieve by patching jOOQ directly.






share|improve this answer






















  • Hi @Lukas, thanks for your reply, it was really insightful. I had a go at overriding DefaultVisitLister (I need to render the sql string) but I am struggling in getting to replace the quotes with brackets using render context. This is what I tried context.renderContext().render().replaceAll("[]","[");` but I get NullPointer
    – user1272052
    Nov 15 at 12:46











  • @user1272052: I'll be happy to answer new questions with examples, showing what you did and more info about the problem you're getting.
    – Lukas Eder
    Nov 16 at 8:08















2














You could indeed implement an ExecuteListener that replaces



  • every odd " by a and every even " by a using any dialect (be careful of syntactic ambiguities)

  • every odd ` by a and every even ` by a using MySQL dialect

  • every [ by a and every ] by a using SQL Server dialect

But from what I can tell, that won't be the only thing you'll be patching in generated SQL, so you might as well fork the jOOQ Open Source Edition and patch the relevant code yourself.



Beware, jOOQ doesn't really support this particular dialect. This will not be the only thing you'll run into. For example, you could try to pattern match subqueries in an ExecuteListener and wrap them in ... , but that, too, would be much easier to achieve by patching jOOQ directly.






share|improve this answer






















  • Hi @Lukas, thanks for your reply, it was really insightful. I had a go at overriding DefaultVisitLister (I need to render the sql string) but I am struggling in getting to replace the quotes with brackets using render context. This is what I tried context.renderContext().render().replaceAll("[]","[");` but I get NullPointer
    – user1272052
    Nov 15 at 12:46











  • @user1272052: I'll be happy to answer new questions with examples, showing what you did and more info about the problem you're getting.
    – Lukas Eder
    Nov 16 at 8:08













2












2








2






You could indeed implement an ExecuteListener that replaces



  • every odd " by a and every even " by a using any dialect (be careful of syntactic ambiguities)

  • every odd ` by a and every even ` by a using MySQL dialect

  • every [ by a and every ] by a using SQL Server dialect

But from what I can tell, that won't be the only thing you'll be patching in generated SQL, so you might as well fork the jOOQ Open Source Edition and patch the relevant code yourself.



Beware, jOOQ doesn't really support this particular dialect. This will not be the only thing you'll run into. For example, you could try to pattern match subqueries in an ExecuteListener and wrap them in ... , but that, too, would be much easier to achieve by patching jOOQ directly.






share|improve this answer














You could indeed implement an ExecuteListener that replaces



  • every odd " by a and every even " by a using any dialect (be careful of syntactic ambiguities)

  • every odd ` by a and every even ` by a using MySQL dialect

  • every [ by a and every ] by a using SQL Server dialect

But from what I can tell, that won't be the only thing you'll be patching in generated SQL, so you might as well fork the jOOQ Open Source Edition and patch the relevant code yourself.



Beware, jOOQ doesn't really support this particular dialect. This will not be the only thing you'll run into. For example, you could try to pattern match subqueries in an ExecuteListener and wrap them in ... , but that, too, would be much easier to achieve by patching jOOQ directly.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 13 at 10:26

























answered Nov 13 at 9:59









Lukas Eder

132k70429937




132k70429937











  • Hi @Lukas, thanks for your reply, it was really insightful. I had a go at overriding DefaultVisitLister (I need to render the sql string) but I am struggling in getting to replace the quotes with brackets using render context. This is what I tried context.renderContext().render().replaceAll("[]","[");` but I get NullPointer
    – user1272052
    Nov 15 at 12:46











  • @user1272052: I'll be happy to answer new questions with examples, showing what you did and more info about the problem you're getting.
    – Lukas Eder
    Nov 16 at 8:08
















  • Hi @Lukas, thanks for your reply, it was really insightful. I had a go at overriding DefaultVisitLister (I need to render the sql string) but I am struggling in getting to replace the quotes with brackets using render context. This is what I tried context.renderContext().render().replaceAll("[]","[");` but I get NullPointer
    – user1272052
    Nov 15 at 12:46











  • @user1272052: I'll be happy to answer new questions with examples, showing what you did and more info about the problem you're getting.
    – Lukas Eder
    Nov 16 at 8:08















Hi @Lukas, thanks for your reply, it was really insightful. I had a go at overriding DefaultVisitLister (I need to render the sql string) but I am struggling in getting to replace the quotes with brackets using render context. This is what I tried context.renderContext().render().replaceAll("[]","[");` but I get NullPointer
– user1272052
Nov 15 at 12:46





Hi @Lukas, thanks for your reply, it was really insightful. I had a go at overriding DefaultVisitLister (I need to render the sql string) but I am struggling in getting to replace the quotes with brackets using render context. This is what I tried context.renderContext().render().replaceAll("[]","[");` but I get NullPointer
– user1272052
Nov 15 at 12:46













@user1272052: I'll be happy to answer new questions with examples, showing what you did and more info about the problem you're getting.
– Lukas Eder
Nov 16 at 8:08




@user1272052: I'll be happy to answer new questions with examples, showing what you did and more info about the problem you're getting.
– Lukas Eder
Nov 16 at 8:08

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53264890%2fhow-do-i-wrap-brackets-around-parameter-values-when-using-jooq%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Top Tejano songwriter Luis Silva dead of heart attack at 64

ReactJS Fetched API data displays live - need Data displayed static

政党