I would like to use wait(int) as the method signature in a free API (used for http://www.jooq.org ). The goal is to be able to create SQL queries like this example:
SELECT * FROM T_AUTHOR WHERE ROWNUM <= 1 FOR UPDATE OF FIRST_NAME, LAST_NAME WAIT 5
The full FOR UPDATE clause syntax specification (at least for Oracle) can be seen here:
FOR UPDATE [ OF [ [ schema. ] { table | view } . ] column [, [ [ schema. ] { table | view } . ] column]...] [ { NOWAIT | WAIT integer | SKIP LOCKED } ]
http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/img_text/for_update_clause.htm
With jOOQ, I really want to stay close to SQL syntax. So I would like to be able to simulate the above SQL statement with a white jOOQ API as follows:
Result<Record> result = create.select() .from(T_AUTHOR) .limit(1) .forUpdate() .of(FIRST_NAME, LAST_NAME) .wait(5)
The fetch method is used to render the object underlying the API like SQL and run an SQL query on an Oracle database (or any other). The above can be legally specified in the interface:
public interface SelectForUpdateWaitStep extends SelectFinalStep {
I have some doubts about this because there is a risk of collision with another method:
public class Object {
Thanks to the overload method ( int vs. long ), I can do this. But I am afraid that this may confuse my users and lead to errors. So that would be wrong:
.forUpdate() .of(FIRST_NAME, LAST_NAME) .wait((long) 5)
So my questions are:
- Is there any way to prevent calling / access to
Object.wait(long) altoghether? I don’t think so because he declared final , but maybe someone knows a trick compiler or something else? - Do you have a better idea for my API design besides just renaming the method to something stupid like
doWait(int) or wait(int) ?
source share