From c742587adddf1ffc92e7f618e06c59bd7de874fe Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Fri, 11 Jul 2014 10:32:28 +0200 Subject: [PATCH] [#3389] Add DSLContext.currval(String) and nextval(String) for convenience --- jOOQ/src/main/java/org/jooq/DSLContext.java | 22 +++++++++++++++++-- .../java/org/jooq/impl/DefaultDSLContext.java | 10 +++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/jOOQ/src/main/java/org/jooq/DSLContext.java b/jOOQ/src/main/java/org/jooq/DSLContext.java index 10aea3009a..7b6a79e944 100644 --- a/jOOQ/src/main/java/org/jooq/DSLContext.java +++ b/jOOQ/src/main/java/org/jooq/DSLContext.java @@ -4790,7 +4790,16 @@ public interface DSLContext { /** * Convenience method to fetch the NEXTVAL for a sequence directly from this - * {@link DSLContext}'s underlying JDBC {@link Connection} + * {@link DSLContext}'s underlying JDBC {@link Connection}. + * + * @throws DataAccessException if something went wrong executing the query + */ + @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, POSTGRES }) + BigInteger nextval(String sequence) throws DataAccessException; + + /** + * Convenience method to fetch the NEXTVAL for a sequence directly from this + * {@link DSLContext}'s underlying JDBC {@link Connection}. * * @throws DataAccessException if something went wrong executing the query */ @@ -4799,7 +4808,16 @@ public interface DSLContext { /** * Convenience method to fetch the CURRVAL for a sequence directly from this - * {@link DSLContext}'s underlying JDBC {@link Connection} + * {@link DSLContext}'s underlying JDBC {@link Connection}. + * + * @throws DataAccessException if something went wrong executing the query + */ + @Support({ CUBRID, FIREBIRD, H2, POSTGRES }) + BigInteger currval(String sequence) throws DataAccessException; + + /** + * Convenience method to fetch the CURRVAL for a sequence directly from this + * {@link DSLContext}'s underlying JDBC {@link Connection}. * * @throws DataAccessException if something went wrong executing the query */ diff --git a/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java b/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java index 1641523ffc..f7e837bd28 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java +++ b/jOOQ/src/main/java/org/jooq/impl/DefaultDSLContext.java @@ -1678,12 +1678,22 @@ public class DefaultDSLContext implements DSLContext, Serializable { } } + @Override + public BigInteger nextval(String sequence) { + return nextval(sequence(sequence)); + } + @Override public T nextval(Sequence sequence) { Field nextval = sequence.nextval(); return select(nextval).fetchOne(nextval); } + @Override + public BigInteger currval(String sequence) { + return currval(sequence(sequence)); + } + @Override public T currval(Sequence sequence) { Field currval = sequence.currval();