├── .gitignore ├── vertx-jooq-async-shared ├── src │ └── main │ │ └── java │ │ └── io │ │ └── github │ │ └── jklingsporn │ │ └── vertx │ │ └── jooq │ │ └── async │ │ └── shared │ │ ├── VertxPojo.java │ │ ├── JsonArrayConverter.java │ │ ├── JsonObjectConverter.java │ │ └── internal │ │ └── VertxDAOHelper.java └── pom.xml ├── vertx-jooq-async-generate ├── src │ ├── main │ │ └── java │ │ │ └── io │ │ │ └── github │ │ │ └── jklingsporn │ │ │ └── vertx │ │ │ └── jooq │ │ │ └── async │ │ │ └── generate │ │ │ ├── rx │ │ │ ├── RXAsyncGeneratorStrategy.java │ │ │ ├── RXAsyncVertxGenerator.java │ │ │ └── RXAsyncVertxGuiceGenerator.java │ │ │ ├── future │ │ │ ├── FutureAsyncGeneratorStrategy.java │ │ │ ├── FutureAsyncVertxGuiceGenerator.java │ │ │ └── FutureAsyncVertxGenerator.java │ │ │ ├── classic │ │ │ ├── ClassicAsyncGeneratorStrategy.java │ │ │ ├── ClassicAsyncVertxGuiceGenerator.java │ │ │ └── ClassicAsyncVertxGenerator.java │ │ │ ├── VertxJavaWriter.java │ │ │ └── VertxGeneratorStrategy.java │ └── test │ │ ├── resources │ │ └── logback.xml │ │ └── java │ │ ├── io │ │ └── github │ │ │ └── jklingsporn │ │ │ └── vertx │ │ │ └── jooq │ │ │ └── async │ │ │ └── generate │ │ │ ├── rx │ │ │ ├── JsonConversionTest.java │ │ │ ├── VertxGeneratorTest.java │ │ │ ├── VertxSomethingCompositeDaoTest.java │ │ │ └── RXVertxDaoTestBase.java │ │ │ ├── future │ │ │ ├── JsonConversionTest.java │ │ │ ├── VertxGeneratorTest.java │ │ │ ├── VertxDaoTestBase.java │ │ │ └── VertxSomethingCompositeDaoTest.java │ │ │ └── classic │ │ │ ├── VertxGeneratorTest.java │ │ │ ├── JsonConversionTest.java │ │ │ ├── VertxSomethingCompositeDaoTest.java │ │ │ └── VertxDaoTestBase.java │ │ └── generated │ │ ├── rx │ │ └── async │ │ │ └── vertx │ │ │ ├── Tables.java │ │ │ ├── DefaultCatalog.java │ │ │ ├── Indexes.java │ │ │ ├── DefaultSchema.java │ │ │ ├── tables │ │ │ ├── interfaces │ │ │ │ ├── ISomethingwithoutjson.java │ │ │ │ ├── ISomethingcomposite.java │ │ │ │ └── ISomething.java │ │ │ ├── pojos │ │ │ │ ├── Somethingwithoutjson.java │ │ │ │ └── Somethingcomposite.java │ │ │ ├── Somethingwithoutjson.java │ │ │ └── Somethingcomposite.java │ │ │ └── Keys.java │ │ ├── future │ │ └── async │ │ │ └── vertx │ │ │ ├── Tables.java │ │ │ ├── DefaultCatalog.java │ │ │ ├── Indexes.java │ │ │ ├── tables │ │ │ ├── interfaces │ │ │ │ ├── ISomethingwithoutjson.java │ │ │ │ └── ISomethingcomposite.java │ │ │ ├── pojos │ │ │ │ ├── Somethingwithoutjson.java │ │ │ │ └── Somethingcomposite.java │ │ │ ├── daos │ │ │ │ ├── SomethingwithoutjsonDao.java │ │ │ │ └── SomethingcompositeDao.java │ │ │ ├── Somethingwithoutjson.java │ │ │ └── Somethingcomposite.java │ │ │ ├── DefaultSchema.java │ │ │ └── Keys.java │ │ └── classic │ │ └── async │ │ └── vertx │ │ ├── Tables.java │ │ ├── DefaultCatalog.java │ │ ├── Indexes.java │ │ ├── tables │ │ ├── interfaces │ │ │ ├── ISomethingwithoutjson.java │ │ │ └── ISomethingcomposite.java │ │ ├── pojos │ │ │ ├── Somethingwithoutjson.java │ │ │ └── Somethingcomposite.java │ │ ├── daos │ │ │ └── SomethingwithoutjsonDao.java │ │ ├── Somethingwithoutjson.java │ │ └── Somethingcomposite.java │ │ ├── DefaultSchema.java │ │ └── Keys.java └── pom.xml ├── vertx-jooq-async-classic ├── pom.xml └── src │ └── main │ └── java │ └── io │ └── github │ └── jklingsporn │ └── vertx │ └── jooq │ └── async │ └── classic │ └── AsyncJooqSQLClient.java ├── vertx-jooq-async-future ├── pom.xml └── src │ └── main │ └── java │ └── io │ └── github │ └── jklingsporn │ └── vertx │ └── jooq │ └── async │ └── future │ ├── AsyncJooqSQLClient.java │ └── impl │ └── AsyncJooqSQLClientImpl.java ├── LICENSE └── vertx-jooq-async-rx ├── pom.xml └── src ├── main └── java │ └── io │ └── github │ └── jklingsporn │ └── vertx │ └── jooq │ └── async │ └── rx │ ├── util │ ├── RXTool.java │ └── AsyncJooqSQLClientImpl.java │ └── AsyncJooqSQLClient.java └── test └── java └── io └── github └── jklingsporn └── vertx └── jooq └── async └── rx └── util └── RXToolTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | *.iml 3 | *.iws 4 | .vertx/ 5 | target/ -------------------------------------------------------------------------------- /vertx-jooq-async-shared/src/main/java/io/github/jklingsporn/vertx/jooq/async/shared/VertxPojo.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.shared; 2 | 3 | /** 4 | * Created by jensklingsporn on 13.06.17. 5 | */ 6 | public interface VertxPojo { 7 | 8 | public VertxPojo fromJson(io.vertx.core.json.JsonObject json); 9 | 10 | public io.vertx.core.json.JsonObject toJson(); 11 | } 12 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/main/java/io/github/jklingsporn/vertx/jooq/async/generate/rx/RXAsyncGeneratorStrategy.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.generate.rx; 2 | 3 | import io.github.jklingsporn.vertx.jooq.async.generate.VertxGeneratorStrategy; 4 | 5 | public class RXAsyncGeneratorStrategy extends VertxGeneratorStrategy { 6 | 7 | public RXAsyncGeneratorStrategy() { 8 | super(RXAsyncVertxGenerator.VERTX_DAO_NAME); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | System.out 6 | 7 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /vertx-jooq-async-shared/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | vertx-jooq-async 7 | io.github.jklingsporn 8 | 0.4 9 | 10 | 4.0.0 11 | jar 12 | vertx-jooq-async-shared 13 | 14 | 15 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/main/java/io/github/jklingsporn/vertx/jooq/async/generate/future/FutureAsyncGeneratorStrategy.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.generate.future; 2 | 3 | import io.github.jklingsporn.vertx.jooq.async.generate.VertxGeneratorStrategy; 4 | 5 | /** 6 | * Created by jensklingsporn on 25.10.16. 7 | * 8 | * We need this class to let the DAOs implements VertxDAO. 9 | * Unfortunately we can not get the type easily, that's why we have to 10 | * set the placeholder. 11 | */ 12 | public class FutureAsyncGeneratorStrategy extends VertxGeneratorStrategy { 13 | 14 | public FutureAsyncGeneratorStrategy() { 15 | super(FutureAsyncVertxGenerator.VERTX_DAO_NAME); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/main/java/io/github/jklingsporn/vertx/jooq/async/generate/classic/ClassicAsyncGeneratorStrategy.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.generate.classic; 2 | 3 | import io.github.jklingsporn.vertx.jooq.async.generate.VertxGeneratorStrategy; 4 | 5 | /** 6 | * Created by jensklingsporn on 25.10.16. 7 | * 8 | * We need this class to let the DAOs implements VertxDAO. 9 | * Unfortunately we can not get the type easily, that's why we have to 10 | * set the placeholder. 11 | */ 12 | public class ClassicAsyncGeneratorStrategy extends VertxGeneratorStrategy { 13 | 14 | public ClassicAsyncGeneratorStrategy() { 15 | super(ClassicAsyncVertxGenerator.VERTX_DAO_NAME); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /vertx-jooq-async-classic/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | vertx-jooq-async 7 | io.github.jklingsporn 8 | 0.4 9 | 10 | 4.0.0 11 | jar 12 | vertx-jooq-async-classic 13 | 14 | 15 | 16 | io.github.jklingsporn 17 | vertx-jooq-async-shared 18 | ${project.version} 19 | 20 | 21 | -------------------------------------------------------------------------------- /vertx-jooq-async-future/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | vertx-jooq-async 7 | io.github.jklingsporn 8 | 0.4 9 | 10 | 4.0.0 11 | 12 | vertx-jooq-async-future 13 | 14 | 15 | me.escoffier.vertx 16 | vertx-completable-future 17 | 0.1.1 18 | 19 | 20 | io.github.jklingsporn 21 | vertx-jooq-async-shared 22 | ${project.version} 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/io/github/jklingsporn/vertx/jooq/async/generate/rx/JsonConversionTest.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.generate.rx; 2 | 3 | import generated.rx.async.vertx.tables.pojos.Something; 4 | import io.vertx.core.json.JsonObject; 5 | import org.junit.Assert; 6 | import org.junit.Test; 7 | 8 | /** 9 | * Created by jensklingsporn on 22.08.17. 10 | */ 11 | public class JsonConversionTest { 12 | 13 | @Test 14 | public void convertEmptyPojoToJsonShouldSucceed(){ 15 | Something something = new Something(); 16 | Assert.assertNotNull(something.toJson()); 17 | } 18 | 19 | @Test 20 | public void convertEmptyJsonToPojoShouldSucceed(){ 21 | Something something = new Something(new JsonObject()); 22 | Assert.assertNotNull(something); 23 | } 24 | 25 | @Test 26 | public void convertJsonWithNullValuesToPojoShouldSucceed(){ 27 | Something something = new Something(); 28 | JsonObject jsonObject = something.toJson(); 29 | Assert.assertNotNull(new Something(jsonObject)); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/io/github/jklingsporn/vertx/jooq/async/generate/future/JsonConversionTest.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.generate.future; 2 | 3 | import generated.future.async.vertx.tables.pojos.Something; 4 | import io.vertx.core.json.JsonObject; 5 | import org.junit.Assert; 6 | import org.junit.Test; 7 | 8 | /** 9 | * Created by jensklingsporn on 22.08.17. 10 | */ 11 | public class JsonConversionTest { 12 | 13 | @Test 14 | public void convertEmptyPojoToJsonShouldSucceed(){ 15 | Something something = new Something(); 16 | Assert.assertNotNull(something.toJson()); 17 | } 18 | 19 | @Test 20 | public void convertEmptyJsonToPojoShouldSucceed(){ 21 | Something something = new Something(new JsonObject()); 22 | Assert.assertNotNull(something); 23 | } 24 | 25 | @Test 26 | public void convertJsonWithNullValuesToPojoShouldSucceed(){ 27 | Something something = new Something(); 28 | JsonObject jsonObject = something.toJson(); 29 | Assert.assertNotNull(new Something(jsonObject)); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 jklingsporn 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /vertx-jooq-async-shared/src/main/java/io/github/jklingsporn/vertx/jooq/async/shared/JsonArrayConverter.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.shared; 2 | 3 | import io.vertx.core.json.JsonArray; 4 | import org.jooq.Converter; 5 | 6 | /** 7 | * Created by jensklingsporn on 04.10.16. 8 | * Use this converter to convert any varchar/String column into a JsonArray. 9 | */ 10 | public class JsonArrayConverter implements Converter { 11 | 12 | private static JsonArrayConverter INSTANCE; 13 | public static JsonArrayConverter getInstance() { 14 | return INSTANCE == null ? INSTANCE = new JsonArrayConverter() : INSTANCE; 15 | } 16 | 17 | @Override 18 | public JsonArray from(String databaseObject) { 19 | return databaseObject==null?null:new JsonArray(databaseObject); 20 | } 21 | 22 | @Override 23 | public String to(JsonArray userObject) { 24 | return userObject==null?null:userObject.encode(); 25 | } 26 | 27 | @Override 28 | public Class fromType() { 29 | return String.class; 30 | } 31 | 32 | @Override 33 | public Class toType() { 34 | return JsonArray.class; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /vertx-jooq-async-shared/src/main/java/io/github/jklingsporn/vertx/jooq/async/shared/JsonObjectConverter.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.shared; 2 | 3 | import io.vertx.core.json.JsonObject; 4 | import org.jooq.Converter; 5 | 6 | /** 7 | * Created by jensklingsporn on 04.10.16. 8 | * Use this converter to convert any varchar/String column into a JsonObject. 9 | */ 10 | public class JsonObjectConverter implements Converter { 11 | 12 | private static JsonObjectConverter INSTANCE; 13 | public static JsonObjectConverter getInstance() { 14 | return INSTANCE == null ? INSTANCE = new JsonObjectConverter() : INSTANCE; 15 | } 16 | 17 | @Override 18 | public JsonObject from(String databaseObject) { 19 | return databaseObject==null?null:new JsonObject(databaseObject); 20 | } 21 | 22 | @Override 23 | public String to(JsonObject userObject) { 24 | return userObject==null?null:userObject.encode(); 25 | } 26 | 27 | @Override 28 | public Class fromType() { 29 | return String.class; 30 | } 31 | 32 | @Override 33 | public Class toType() { 34 | return JsonObject.class; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/io/github/jklingsporn/vertx/jooq/async/generate/future/VertxGeneratorTest.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.generate.future; 2 | 3 | import io.github.jklingsporn.vertx.jooq.async.generate.TestTool; 4 | import org.jooq.util.GenerationTool; 5 | import org.jooq.util.jaxb.Configuration; 6 | import org.junit.Assert; 7 | import org.junit.BeforeClass; 8 | import org.junit.Test; 9 | 10 | import java.sql.SQLException; 11 | 12 | /** 13 | * Created by jklingsporn on 17.09.16. 14 | */ 15 | public class VertxGeneratorTest { 16 | 17 | @BeforeClass 18 | public static void createTestSchema() throws SQLException { 19 | TestTool.setupDB(); 20 | } 21 | 22 | @Test 23 | public void generateCodeShouldSucceed() throws Exception { 24 | Configuration configuration = TestTool.createGeneratorConfig( 25 | FutureAsyncVertxGenerator.class.getName(),"future.async.vertx", FutureAsyncGeneratorStrategy.class); 26 | try { 27 | GenerationTool.generate(configuration); 28 | Assert.assertTrue(true); 29 | } catch (Exception e) { 30 | e.printStackTrace(); 31 | Assert.fail(e.getMessage()); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/io/github/jklingsporn/vertx/jooq/async/generate/classic/VertxGeneratorTest.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.generate.classic; 2 | 3 | import io.github.jklingsporn.vertx.jooq.async.generate.TestTool; 4 | import org.jooq.util.GenerationTool; 5 | import org.jooq.util.jaxb.Configuration; 6 | import org.junit.Assert; 7 | import org.junit.BeforeClass; 8 | import org.junit.Test; 9 | 10 | import java.sql.SQLException; 11 | 12 | /** 13 | * Created by jklingsporn on 17.09.16. 14 | */ 15 | public class VertxGeneratorTest { 16 | 17 | @BeforeClass 18 | public static void createTestSchema() throws SQLException { 19 | TestTool.setupDB();; 20 | } 21 | 22 | @Test 23 | public void generateCodeShouldSucceed() throws Exception { 24 | Configuration configuration = TestTool.createGeneratorConfig( 25 | ClassicAsyncVertxGenerator.class.getName(),"classic.async.vertx", ClassicAsyncGeneratorStrategy.class); 26 | try { 27 | GenerationTool.generate(configuration); 28 | Assert.assertTrue(true); 29 | } catch (Exception e) { 30 | e.printStackTrace(); 31 | Assert.fail(e.getMessage()); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /vertx-jooq-async-rx/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | vertx-jooq-async 7 | io.github.jklingsporn 8 | 0.4 9 | 10 | 4.0.0 11 | jar 12 | vertx-jooq-async-rx 13 | 14 | 15 | 16 | io.reactivex.rxjava2 17 | rxjava 18 | ${rx.version} 19 | 20 | 21 | io.vertx 22 | vertx-rx-java2 23 | ${vertx.version} 24 | 25 | 26 | io.github.jklingsporn 27 | vertx-jooq-async-shared 28 | ${project.version} 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/io/github/jklingsporn/vertx/jooq/async/generate/rx/VertxGeneratorTest.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.generate.rx; 2 | 3 | import io.github.jklingsporn.vertx.jooq.async.generate.TestTool; 4 | import org.jooq.util.GenerationTool; 5 | import org.jooq.util.jaxb.Configuration; 6 | import org.junit.Assert; 7 | import org.junit.BeforeClass; 8 | import org.junit.Test; 9 | 10 | import java.sql.SQLException; 11 | 12 | /** 13 | * @author Clement Escoffier 14 | * @author Jens Klingsporn 15 | */ 16 | public class VertxGeneratorTest { 17 | 18 | @BeforeClass 19 | public static void createTestSchema() throws SQLException { 20 | TestTool.setupDB(); 21 | } 22 | 23 | @Test 24 | public void generateCodeShouldSucceed() throws Exception { 25 | Configuration configuration = TestTool.createGeneratorConfig( 26 | RXAsyncVertxGenerator.class.getName(), "rx.async.vertx", RXAsyncGeneratorStrategy.class); 27 | try { 28 | GenerationTool.generate(configuration); 29 | Assert.assertTrue(true); 30 | } catch (Exception e) { 31 | e.printStackTrace(); 32 | Assert.fail(e.getMessage()); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/rx/async/vertx/Tables.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.rx.async.vertx; 5 | 6 | 7 | import generated.rx.async.vertx.tables.Something; 8 | import generated.rx.async.vertx.tables.Somethingcomposite; 9 | import generated.rx.async.vertx.tables.Somethingwithoutjson; 10 | 11 | import javax.annotation.Generated; 12 | 13 | 14 | /** 15 | * Convenience access to all tables in 16 | */ 17 | @Generated( 18 | value = { 19 | "http://www.jooq.org", 20 | "jOOQ version:3.10.1" 21 | }, 22 | comments = "This class is generated by jOOQ" 23 | ) 24 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 25 | public class Tables { 26 | 27 | /** 28 | * The table something. 29 | */ 30 | public static final Something SOMETHING = generated.rx.async.vertx.tables.Something.SOMETHING; 31 | 32 | /** 33 | * The table somethingComposite. 34 | */ 35 | public static final Somethingcomposite SOMETHINGCOMPOSITE = generated.rx.async.vertx.tables.Somethingcomposite.SOMETHINGCOMPOSITE; 36 | 37 | /** 38 | * The table somethingWithoutJson. 39 | */ 40 | public static final Somethingwithoutjson SOMETHINGWITHOUTJSON = generated.rx.async.vertx.tables.Somethingwithoutjson.SOMETHINGWITHOUTJSON; 41 | } 42 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/future/async/vertx/Tables.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.future.async.vertx; 5 | 6 | 7 | import generated.future.async.vertx.tables.Something; 8 | import generated.future.async.vertx.tables.Somethingcomposite; 9 | import generated.future.async.vertx.tables.Somethingwithoutjson; 10 | 11 | import javax.annotation.Generated; 12 | 13 | 14 | /** 15 | * Convenience access to all tables in 16 | */ 17 | @Generated( 18 | value = { 19 | "http://www.jooq.org", 20 | "jOOQ version:3.10.1" 21 | }, 22 | comments = "This class is generated by jOOQ" 23 | ) 24 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 25 | public class Tables { 26 | 27 | /** 28 | * The table something. 29 | */ 30 | public static final Something SOMETHING = generated.future.async.vertx.tables.Something.SOMETHING; 31 | 32 | /** 33 | * The table somethingComposite. 34 | */ 35 | public static final Somethingcomposite SOMETHINGCOMPOSITE = generated.future.async.vertx.tables.Somethingcomposite.SOMETHINGCOMPOSITE; 36 | 37 | /** 38 | * The table somethingWithoutJson. 39 | */ 40 | public static final Somethingwithoutjson SOMETHINGWITHOUTJSON = generated.future.async.vertx.tables.Somethingwithoutjson.SOMETHINGWITHOUTJSON; 41 | } 42 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/classic/async/vertx/Tables.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.classic.async.vertx; 5 | 6 | 7 | import generated.classic.async.vertx.tables.Something; 8 | import generated.classic.async.vertx.tables.Somethingcomposite; 9 | import generated.classic.async.vertx.tables.Somethingwithoutjson; 10 | 11 | import javax.annotation.Generated; 12 | 13 | 14 | /** 15 | * Convenience access to all tables in 16 | */ 17 | @Generated( 18 | value = { 19 | "http://www.jooq.org", 20 | "jOOQ version:3.10.1" 21 | }, 22 | comments = "This class is generated by jOOQ" 23 | ) 24 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 25 | public class Tables { 26 | 27 | /** 28 | * The table something. 29 | */ 30 | public static final Something SOMETHING = generated.classic.async.vertx.tables.Something.SOMETHING; 31 | 32 | /** 33 | * The table somethingComposite. 34 | */ 35 | public static final Somethingcomposite SOMETHINGCOMPOSITE = generated.classic.async.vertx.tables.Somethingcomposite.SOMETHINGCOMPOSITE; 36 | 37 | /** 38 | * The table somethingWithoutJson. 39 | */ 40 | public static final Somethingwithoutjson SOMETHINGWITHOUTJSON = generated.classic.async.vertx.tables.Somethingwithoutjson.SOMETHINGWITHOUTJSON; 41 | } 42 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/io/github/jklingsporn/vertx/jooq/async/generate/classic/JsonConversionTest.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.generate.classic; 2 | 3 | import generated.classic.async.vertx.tables.pojos.Something; 4 | import io.vertx.core.json.JsonObject; 5 | import org.junit.Assert; 6 | import org.junit.Test; 7 | 8 | /** 9 | * Created by jensklingsporn on 22.08.17. 10 | */ 11 | public class JsonConversionTest { 12 | 13 | @Test 14 | public void convertEmptyPojoToJsonShouldSucceed(){ 15 | Something something = new Something(); 16 | Assert.assertNotNull(something.toJson()); 17 | } 18 | 19 | @Test 20 | public void convertEmptyJsonToPojoShouldSucceed(){ 21 | Something something = new Something(new JsonObject()); 22 | Assert.assertNotNull(something); 23 | } 24 | 25 | @Test 26 | public void convertJsonWithNullValuesToPojoShouldSucceed(){ 27 | Something something = new Something(); 28 | JsonObject jsonObject = something.toJson(); 29 | Assert.assertNotNull(new Something(jsonObject)); 30 | } 31 | 32 | @Test 33 | public void convertFromToJsonShouldReturnEqualPOJO(){ 34 | Something something = VertxDaoTestBase.createSomethingWithId(); 35 | JsonObject json = something.toJson(); 36 | Something somethingElse = new Something(json); 37 | Assert.assertEquals(something,somethingElse); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/main/java/io/github/jklingsporn/vertx/jooq/async/generate/VertxJavaWriter.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.generate; 2 | 3 | import org.jooq.util.JavaWriter; 4 | 5 | import java.io.File; 6 | 7 | /** 8 | * Replaces the DAO type in the generated class with the actual type. The type 9 | * is set externally by invoking the #setDaoTypeReplacement method 10 | * from the AbstractVertxGenerator. 11 | */ 12 | public class VertxJavaWriter extends JavaWriter { 13 | 14 | public static final String PLACEHOLDER_DAO_TYPE = "__DAO_TYPE__"; 15 | private String daoTypeReplacement; 16 | 17 | public VertxJavaWriter(File file, String fullyQualifiedTypes) { 18 | super(file, fullyQualifiedTypes); 19 | } 20 | 21 | public VertxJavaWriter(File file, String fullyQualifiedTypes, String encoding) { 22 | super(file, fullyQualifiedTypes, encoding); 23 | } 24 | 25 | public void setDaoTypeReplacement(String daoTypeReplacement) { 26 | this.daoTypeReplacement = daoTypeReplacement; 27 | } 28 | 29 | @Override 30 | protected String beforeClose(String string) { 31 | return super.beforeClose(string.replaceAll(PLACEHOLDER_DAO_TYPE, daoTypeReplacement)); 32 | } 33 | 34 | @Override 35 | public String ref(String clazzOrId, int keepSegments) { 36 | return super.ref(clazzOrId, keepSegments); 37 | } 38 | 39 | @Override 40 | public String ref(String clazz) { 41 | return super.ref(clazz); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /vertx-jooq-async-rx/src/main/java/io/github/jklingsporn/vertx/jooq/async/rx/util/RXTool.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.rx.util; 2 | 3 | import io.reactivex.Observable; 4 | import io.reactivex.Single; 5 | import io.vertx.core.Handler; 6 | import io.vertx.reactivex.core.Future; 7 | import io.vertx.reactivex.core.Vertx; 8 | 9 | import java.util.List; 10 | import java.util.function.Function; 11 | 12 | /** 13 | * @author Clement Escoffier 14 | */ 15 | public class RXTool { 16 | private RXTool() { 17 | } 18 | 19 | 20 | public static Single executeBlocking(Handler> blockingCodeHandler, Vertx 21 | vertx) { 22 | return vertx.rxExecuteBlocking(blockingCodeHandler); 23 | } 24 | 25 | public static Observable executeBlockingObservable(Handler>> blockingCodeHandler, Vertx 26 | vertx) { 27 | return executeBlocking(blockingCodeHandler,vertx) 28 | .flatMapObservable(Observable::fromIterable); 29 | } 30 | 31 | 32 | 33 | public static Single failure(Throwable e) { 34 | return Single.error(e); 35 | } 36 | 37 | /** 38 | * Converts a java.util.function into a io.reactivex.functions.Function. 39 | * @param f the java function 40 | * @param 41 | * @param 42 | * @return the reactivex Function 43 | */ 44 | public static io.reactivex.functions.Function toFunction(Function f){ 45 | return f::apply; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/main/java/io/github/jklingsporn/vertx/jooq/async/generate/VertxGeneratorStrategy.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.generate; 2 | 3 | import io.github.jklingsporn.vertx.jooq.async.shared.VertxPojo; 4 | import org.jooq.util.DefaultGeneratorStrategy; 5 | import org.jooq.util.Definition; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by jensklingsporn on 25.10.16. 11 | * 12 | * We need this class to let the DAOs implements VertxDAO. 13 | * Unfortunately we can not get the type easily, that's why we have to 14 | * set the placeholder. 15 | */ 16 | public class VertxGeneratorStrategy extends DefaultGeneratorStrategy { 17 | 18 | private final String daoClassName; 19 | 20 | public VertxGeneratorStrategy(String daoClassName) { 21 | this.daoClassName = daoClassName; 22 | } 23 | 24 | @Override 25 | public List getJavaClassImplements(Definition definition, Mode mode) { 26 | List javaClassImplements = super.getJavaClassImplements(definition, mode); 27 | if(mode.equals(Mode.DAO)){ 28 | final String tableRecord = getFullJavaClassName(definition, Mode.RECORD); 29 | final String pType = getFullJavaClassName(definition, Mode.POJO); 30 | javaClassImplements.add(String.format("%s<%s,%s,%s>",daoClassName,tableRecord,pType, VertxJavaWriter.PLACEHOLDER_DAO_TYPE)); 31 | }else if(mode.equals(Mode.INTERFACE)){ 32 | javaClassImplements.add(VertxPojo.class.getName()); 33 | } 34 | return javaClassImplements; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/rx/async/vertx/DefaultCatalog.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.rx.async.vertx; 5 | 6 | 7 | import java.util.ArrayList; 8 | import java.util.Arrays; 9 | import java.util.List; 10 | 11 | import javax.annotation.Generated; 12 | 13 | import org.jooq.Schema; 14 | import org.jooq.impl.CatalogImpl; 15 | 16 | 17 | /** 18 | * This class is generated by jOOQ. 19 | */ 20 | @Generated( 21 | value = { 22 | "http://www.jooq.org", 23 | "jOOQ version:3.10.1" 24 | }, 25 | comments = "This class is generated by jOOQ" 26 | ) 27 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 28 | public class DefaultCatalog extends CatalogImpl { 29 | 30 | private static final long serialVersionUID = 1300465306; 31 | 32 | /** 33 | * The reference instance of 34 | */ 35 | public static final DefaultCatalog DEFAULT_CATALOG = new DefaultCatalog(); 36 | 37 | /** 38 | * The schema . 39 | */ 40 | public final DefaultSchema DEFAULT_SCHEMA = generated.rx.async.vertx.DefaultSchema.DEFAULT_SCHEMA; 41 | 42 | /** 43 | * No further instances allowed 44 | */ 45 | private DefaultCatalog() { 46 | super(""); 47 | } 48 | 49 | @Override 50 | public final List getSchemas() { 51 | List result = new ArrayList(); 52 | result.addAll(getSchemas0()); 53 | return result; 54 | } 55 | 56 | private final List getSchemas0() { 57 | return Arrays.asList( 58 | DefaultSchema.DEFAULT_SCHEMA); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/classic/async/vertx/DefaultCatalog.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.classic.async.vertx; 5 | 6 | 7 | import java.util.ArrayList; 8 | import java.util.Arrays; 9 | import java.util.List; 10 | 11 | import javax.annotation.Generated; 12 | 13 | import org.jooq.Schema; 14 | import org.jooq.impl.CatalogImpl; 15 | 16 | 17 | /** 18 | * This class is generated by jOOQ. 19 | */ 20 | @Generated( 21 | value = { 22 | "http://www.jooq.org", 23 | "jOOQ version:3.10.1" 24 | }, 25 | comments = "This class is generated by jOOQ" 26 | ) 27 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 28 | public class DefaultCatalog extends CatalogImpl { 29 | 30 | private static final long serialVersionUID = 1151739392; 31 | 32 | /** 33 | * The reference instance of 34 | */ 35 | public static final DefaultCatalog DEFAULT_CATALOG = new DefaultCatalog(); 36 | 37 | /** 38 | * The schema . 39 | */ 40 | public final DefaultSchema DEFAULT_SCHEMA = generated.classic.async.vertx.DefaultSchema.DEFAULT_SCHEMA; 41 | 42 | /** 43 | * No further instances allowed 44 | */ 45 | private DefaultCatalog() { 46 | super(""); 47 | } 48 | 49 | @Override 50 | public final List getSchemas() { 51 | List result = new ArrayList(); 52 | result.addAll(getSchemas0()); 53 | return result; 54 | } 55 | 56 | private final List getSchemas0() { 57 | return Arrays.asList( 58 | DefaultSchema.DEFAULT_SCHEMA); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/future/async/vertx/DefaultCatalog.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.future.async.vertx; 5 | 6 | 7 | import java.util.ArrayList; 8 | import java.util.Arrays; 9 | import java.util.List; 10 | 11 | import javax.annotation.Generated; 12 | 13 | import org.jooq.Schema; 14 | import org.jooq.impl.CatalogImpl; 15 | 16 | 17 | /** 18 | * This class is generated by jOOQ. 19 | */ 20 | @Generated( 21 | value = { 22 | "http://www.jooq.org", 23 | "jOOQ version:3.10.1" 24 | }, 25 | comments = "This class is generated by jOOQ" 26 | ) 27 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 28 | public class DefaultCatalog extends CatalogImpl { 29 | 30 | private static final long serialVersionUID = -1006856646; 31 | 32 | /** 33 | * The reference instance of 34 | */ 35 | public static final DefaultCatalog DEFAULT_CATALOG = new DefaultCatalog(); 36 | 37 | /** 38 | * The schema . 39 | */ 40 | public final DefaultSchema DEFAULT_SCHEMA = generated.future.async.vertx.DefaultSchema.DEFAULT_SCHEMA; 41 | 42 | /** 43 | * No further instances allowed 44 | */ 45 | private DefaultCatalog() { 46 | super(""); 47 | } 48 | 49 | @Override 50 | public final List getSchemas() { 51 | List result = new ArrayList(); 52 | result.addAll(getSchemas0()); 53 | return result; 54 | } 55 | 56 | private final List getSchemas0() { 57 | return Arrays.asList( 58 | DefaultSchema.DEFAULT_SCHEMA); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /vertx-jooq-async-rx/src/main/java/io/github/jklingsporn/vertx/jooq/async/rx/AsyncJooqSQLClient.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.rx; 2 | 3 | import io.github.jklingsporn.vertx.jooq.async.rx.util.AsyncJooqSQLClientImpl; 4 | import io.reactivex.Single; 5 | import io.vertx.core.json.JsonObject; 6 | import io.vertx.reactivex.core.Vertx; 7 | import io.vertx.reactivex.ext.asyncsql.AsyncSQLClient; 8 | import org.jooq.Query; 9 | 10 | import java.util.List; 11 | import java.util.function.Function; 12 | 13 | /** 14 | * Created by jensklingsporn on 13.06.17. 15 | */ 16 | public interface AsyncJooqSQLClient { 17 | 18 | public static AsyncJooqSQLClient create(Vertx vertx, AsyncSQLClient delegate){ 19 | return new AsyncJooqSQLClientImpl(vertx, delegate); 20 | } 21 | 22 | /** 23 | * @param query a jOOQ-query 24 | * @param mapper a function to map the result into another object. 25 | * @param

the type to fetch 26 | * @return A Single returning a List of P. 27 | */ 28 |

Single> fetch(Query query, Function mapper); 29 | 30 | /** 31 | * @param query a jOOQ-query 32 | * @param mapper a function to map the result into another object. 33 | * @param

the type to fetch 34 | * @return A Single returning an object of P or null. 35 | */ 36 |

Single

fetchOne(Query query, Function mapper); 37 | 38 | /** 39 | * @param query a jOOQ-query 40 | * @return A Single returning the number of affected rows by this query. 41 | */ 42 | Single execute(Query query); 43 | 44 | /** 45 | * @param query a jOOQ-query to run the insert statement 46 | * @return A Single returning the lastId returned by mysql. 47 | */ 48 | Single insertReturning(Query query); 49 | 50 | /** 51 | * @return the underlying client 52 | */ 53 | AsyncSQLClient delegate(); 54 | } 55 | -------------------------------------------------------------------------------- /vertx-jooq-async-future/src/main/java/io/github/jklingsporn/vertx/jooq/async/future/AsyncJooqSQLClient.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.future; 2 | 3 | import io.github.jklingsporn.vertx.jooq.async.future.impl.AsyncJooqSQLClientImpl; 4 | import io.vertx.core.Vertx; 5 | import io.vertx.core.json.JsonObject; 6 | import io.vertx.ext.asyncsql.AsyncSQLClient; 7 | import org.jooq.Query; 8 | 9 | import java.util.List; 10 | import java.util.concurrent.CompletableFuture; 11 | import java.util.function.Function; 12 | 13 | /** 14 | * Created by jensklingsporn on 13.06.17. 15 | */ 16 | public interface AsyncJooqSQLClient { 17 | 18 | public static AsyncJooqSQLClient create(Vertx vertx,AsyncSQLClient delegate){ 19 | return new AsyncJooqSQLClientImpl(vertx, delegate); 20 | } 21 | 22 | /** 23 | * 24 | * @param query a jOOQ-query 25 | * @param mapper a function to map the result into another object. 26 | * @param

the type to fetch 27 | * @return A CompletableFuture returning a List of P. 28 | */ 29 |

CompletableFuture> fetch(Query query, Function mapper); 30 | 31 | /** 32 | * @param query a jOOQ-query 33 | * @param mapper a function to map the result into another object. 34 | * @param

the type to fetch 35 | * @return A CompletableFuture returning an object of P or null. 36 | */ 37 |

CompletableFuture

fetchOne(Query query, Function mapper); 38 | 39 | /** 40 | * @param query a jOOQ-query 41 | * @return A CompletableFuture returning the number of affected rows by this query. 42 | */ 43 | CompletableFuture execute(Query query); 44 | 45 | /** 46 | * @param query a jOOQ-query to run the insert 47 | * @return A CompletableFuture returning the last inserted id provided by mysql 48 | */ 49 | CompletableFuture insertReturning(Query query); 50 | 51 | /** 52 | * @return the underlying client 53 | */ 54 | AsyncSQLClient delegate(); 55 | } 56 | -------------------------------------------------------------------------------- /vertx-jooq-async-classic/src/main/java/io/github/jklingsporn/vertx/jooq/async/classic/AsyncJooqSQLClient.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.classic; 2 | 3 | import io.github.jklingsporn.vertx.jooq.async.classic.impl.AsyncJooqSQLClientImpl; 4 | import io.vertx.core.AsyncResult; 5 | import io.vertx.core.Handler; 6 | import io.vertx.core.Vertx; 7 | import io.vertx.core.json.JsonObject; 8 | import io.vertx.ext.asyncsql.AsyncSQLClient; 9 | import org.jooq.Query; 10 | 11 | import java.util.List; 12 | import java.util.function.Function; 13 | 14 | /** 15 | * Created by jensklingsporn on 13.06.17. 16 | */ 17 | public interface AsyncJooqSQLClient { 18 | 19 | public static AsyncJooqSQLClient create(Vertx vertx, AsyncSQLClient delegate){ 20 | return new AsyncJooqSQLClientImpl(vertx, delegate); 21 | } 22 | 23 | /** 24 | * 25 | * @param query a jOOQ-query 26 | * @param mapper a function to map the result into another object. 27 | * @param resultHandler A Handler containing the fetched results, each converted by the mapper. 28 | * @param

the type to fetch 29 | */ 30 |

void fetch(Query query, Function mapper, Handler>> resultHandler); 31 | 32 | /** 33 | * @param query a jOOQ-query 34 | * @param mapper a function to map the result into another object. 35 | * @param resultHandler A Handler containing the fetched result converted by the mapper. 36 | * @param

the type to fetch 37 | */ 38 |

void fetchOne(Query query, Function mapper, Handler> resultHandler); 39 | 40 | /** 41 | * @param query a jOOQ-query 42 | * @param resultHandler A Handler containing the number of affected rows by this query. 43 | */ 44 | void execute(Query query, Handler> resultHandler); 45 | 46 | /** 47 | * @param query a jooq-query to run the insert 48 | * @param resultHandler A Handler containing the last inserted id returned by mysql 49 | */ 50 | void insertReturning(Query query, Handler> resultHandler); 51 | 52 | /** 53 | * @return the underlying client 54 | */ 55 | AsyncSQLClient delegate(); 56 | } 57 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/rx/async/vertx/Indexes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.rx.async.vertx; 5 | 6 | 7 | import generated.rx.async.vertx.tables.Something; 8 | import generated.rx.async.vertx.tables.Somethingcomposite; 9 | import generated.rx.async.vertx.tables.Somethingwithoutjson; 10 | 11 | import javax.annotation.Generated; 12 | 13 | import org.jooq.Index; 14 | import org.jooq.OrderField; 15 | import org.jooq.impl.AbstractKeys; 16 | 17 | 18 | /** 19 | * A class modelling indexes of tables of the schema. 20 | */ 21 | @Generated( 22 | value = { 23 | "http://www.jooq.org", 24 | "jOOQ version:3.10.1" 25 | }, 26 | comments = "This class is generated by jOOQ" 27 | ) 28 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 29 | public class Indexes { 30 | 31 | // ------------------------------------------------------------------------- 32 | // INDEX definitions 33 | // ------------------------------------------------------------------------- 34 | 35 | public static final Index SOMETHING_PRIMARY = Indexes0.SOMETHING_PRIMARY; 36 | public static final Index SOMETHINGCOMPOSITE_PRIMARY = Indexes0.SOMETHINGCOMPOSITE_PRIMARY; 37 | public static final Index SOMETHINGWITHOUTJSON_PRIMARY = Indexes0.SOMETHINGWITHOUTJSON_PRIMARY; 38 | 39 | // ------------------------------------------------------------------------- 40 | // [#1459] distribute members to avoid static initialisers > 64kb 41 | // ------------------------------------------------------------------------- 42 | 43 | private static class Indexes0 extends AbstractKeys { 44 | public static Index SOMETHING_PRIMARY = createIndex("PRIMARY", Something.SOMETHING, new OrderField[] { Something.SOMETHING.SOMEID }, true); 45 | public static Index SOMETHINGCOMPOSITE_PRIMARY = createIndex("PRIMARY", Somethingcomposite.SOMETHINGCOMPOSITE, new OrderField[] { Somethingcomposite.SOMETHINGCOMPOSITE.SOMEID, Somethingcomposite.SOMETHINGCOMPOSITE.SOMESECONDID }, true); 46 | public static Index SOMETHINGWITHOUTJSON_PRIMARY = createIndex("PRIMARY", Somethingwithoutjson.SOMETHINGWITHOUTJSON, new OrderField[] { Somethingwithoutjson.SOMETHINGWITHOUTJSON.SOMEID }, true); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/future/async/vertx/Indexes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.future.async.vertx; 5 | 6 | 7 | import generated.future.async.vertx.tables.Something; 8 | import generated.future.async.vertx.tables.Somethingcomposite; 9 | import generated.future.async.vertx.tables.Somethingwithoutjson; 10 | 11 | import javax.annotation.Generated; 12 | 13 | import org.jooq.Index; 14 | import org.jooq.OrderField; 15 | import org.jooq.impl.AbstractKeys; 16 | 17 | 18 | /** 19 | * A class modelling indexes of tables of the schema. 20 | */ 21 | @Generated( 22 | value = { 23 | "http://www.jooq.org", 24 | "jOOQ version:3.10.1" 25 | }, 26 | comments = "This class is generated by jOOQ" 27 | ) 28 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 29 | public class Indexes { 30 | 31 | // ------------------------------------------------------------------------- 32 | // INDEX definitions 33 | // ------------------------------------------------------------------------- 34 | 35 | public static final Index SOMETHING_PRIMARY = Indexes0.SOMETHING_PRIMARY; 36 | public static final Index SOMETHINGCOMPOSITE_PRIMARY = Indexes0.SOMETHINGCOMPOSITE_PRIMARY; 37 | public static final Index SOMETHINGWITHOUTJSON_PRIMARY = Indexes0.SOMETHINGWITHOUTJSON_PRIMARY; 38 | 39 | // ------------------------------------------------------------------------- 40 | // [#1459] distribute members to avoid static initialisers > 64kb 41 | // ------------------------------------------------------------------------- 42 | 43 | private static class Indexes0 extends AbstractKeys { 44 | public static Index SOMETHING_PRIMARY = createIndex("PRIMARY", Something.SOMETHING, new OrderField[] { Something.SOMETHING.SOMEID }, true); 45 | public static Index SOMETHINGCOMPOSITE_PRIMARY = createIndex("PRIMARY", Somethingcomposite.SOMETHINGCOMPOSITE, new OrderField[] { Somethingcomposite.SOMETHINGCOMPOSITE.SOMEID, Somethingcomposite.SOMETHINGCOMPOSITE.SOMESECONDID }, true); 46 | public static Index SOMETHINGWITHOUTJSON_PRIMARY = createIndex("PRIMARY", Somethingwithoutjson.SOMETHINGWITHOUTJSON, new OrderField[] { Somethingwithoutjson.SOMETHINGWITHOUTJSON.SOMEID }, true); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/classic/async/vertx/Indexes.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.classic.async.vertx; 5 | 6 | 7 | import generated.classic.async.vertx.tables.Something; 8 | import generated.classic.async.vertx.tables.Somethingcomposite; 9 | import generated.classic.async.vertx.tables.Somethingwithoutjson; 10 | 11 | import javax.annotation.Generated; 12 | 13 | import org.jooq.Index; 14 | import org.jooq.OrderField; 15 | import org.jooq.impl.AbstractKeys; 16 | 17 | 18 | /** 19 | * A class modelling indexes of tables of the schema. 20 | */ 21 | @Generated( 22 | value = { 23 | "http://www.jooq.org", 24 | "jOOQ version:3.10.1" 25 | }, 26 | comments = "This class is generated by jOOQ" 27 | ) 28 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 29 | public class Indexes { 30 | 31 | // ------------------------------------------------------------------------- 32 | // INDEX definitions 33 | // ------------------------------------------------------------------------- 34 | 35 | public static final Index SOMETHING_PRIMARY = Indexes0.SOMETHING_PRIMARY; 36 | public static final Index SOMETHINGCOMPOSITE_PRIMARY = Indexes0.SOMETHINGCOMPOSITE_PRIMARY; 37 | public static final Index SOMETHINGWITHOUTJSON_PRIMARY = Indexes0.SOMETHINGWITHOUTJSON_PRIMARY; 38 | 39 | // ------------------------------------------------------------------------- 40 | // [#1459] distribute members to avoid static initialisers > 64kb 41 | // ------------------------------------------------------------------------- 42 | 43 | private static class Indexes0 extends AbstractKeys { 44 | public static Index SOMETHING_PRIMARY = createIndex("PRIMARY", Something.SOMETHING, new OrderField[] { Something.SOMETHING.SOMEID }, true); 45 | public static Index SOMETHINGCOMPOSITE_PRIMARY = createIndex("PRIMARY", Somethingcomposite.SOMETHINGCOMPOSITE, new OrderField[] { Somethingcomposite.SOMETHINGCOMPOSITE.SOMEID, Somethingcomposite.SOMETHINGCOMPOSITE.SOMESECONDID }, true); 46 | public static Index SOMETHINGWITHOUTJSON_PRIMARY = createIndex("PRIMARY", Somethingwithoutjson.SOMETHINGWITHOUTJSON, new OrderField[] { Somethingwithoutjson.SOMETHINGWITHOUTJSON.SOMEID }, true); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | vertx-jooq-async 7 | io.github.jklingsporn 8 | 0.4 9 | 10 | 4.0.0 11 | jar 12 | vertx-jooq-async-generate 13 | 14 | 5.1.37 15 | 16 | 17 | 18 | 19 | 20 | io.github.jklingsporn 21 | vertx-jooq-async-classic 22 | ${project.version} 23 | test 24 | 25 | 26 | io.github.jklingsporn 27 | vertx-jooq-async-future 28 | ${project.version} 29 | test 30 | 31 | 32 | io.github.jklingsporn 33 | vertx-jooq-async-rx 34 | ${project.version} 35 | test 36 | 37 | 38 | io.reactivex.rxjava2 39 | rxjava 40 | ${rx.version} 41 | test 42 | 43 | 44 | mysql 45 | mysql-connector-java 46 | ${mysql.driver.version} 47 | test 48 | 49 | 50 | io.github.jklingsporn 51 | vertx-jooq-async-shared 52 | ${project.version} 53 | 54 | 55 | org.jooq 56 | jooq-codegen 57 | ${jooq.version} 58 | 59 | 60 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/main/java/io/github/jklingsporn/vertx/jooq/async/generate/future/FutureAsyncVertxGuiceGenerator.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.generate.future; 2 | 3 | import io.github.jklingsporn.vertx.jooq.async.generate.AbstractVertxGuiceGenerator; 4 | import org.jooq.util.JavaWriter; 5 | import org.jooq.util.TableDefinition; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by jensklingsporn on 19.04.17. 11 | */ 12 | public class FutureAsyncVertxGuiceGenerator extends AbstractVertxGuiceGenerator { 13 | 14 | public FutureAsyncVertxGuiceGenerator() { 15 | super(FutureAsyncVertxGenerator.VERTX_DAO_NAME); 16 | } 17 | 18 | public FutureAsyncVertxGuiceGenerator(boolean generateJson, boolean generateGuiceModules, boolean generateInjectConfigurationMethod) { 19 | super(FutureAsyncVertxGenerator.VERTX_DAO_NAME, generateJson, generateGuiceModules, generateInjectConfigurationMethod); 20 | } 21 | 22 | @Override 23 | protected void generateDAOImports(JavaWriter out) { 24 | out.println("import java.util.concurrent.CompletableFuture;"); 25 | out.println("import io.github.jklingsporn.vertx.jooq.future.async.impl.FutureTool;"); 26 | } 27 | 28 | @Override 29 | protected void generateFetchOneByMethods(JavaWriter out, String pType, String colName, String colClass, String colType, String colIdentifier) { 30 | out.tab(1).javadoc("Fetch a unique record that has %s = value asynchronously", colName); 31 | 32 | out.tab(1).println("public CompletableFuture<%s> fetchOneBy%sAsync(%s value) {", pType,colClass, colType); 33 | out.tab(2).println("return FutureTool.executeBlocking(h->h.complete(fetchOneBy%s(value)),vertx());", colClass); 34 | out.tab(1).println("}"); 35 | } 36 | 37 | @Override 38 | protected void generateFetchByMethods(JavaWriter out, String pType, String colName, String colClass, String colType, String colIdentifier) { 39 | out.tab(1).javadoc("Fetch records that have %s IN (values) asynchronously", colName); 40 | out.tab(1).println("public CompletableFuture> fetchBy%sAsync(%s<%s> values) {", pType, colClass, List.class, colType); 41 | //out.tab(2).println("return fetch(%s, values);", colIdentifier); 42 | out.tab(2).println("return fetchAsync(%s,values);", colIdentifier); 43 | out.tab(1).println("}"); 44 | } 45 | 46 | @Override 47 | protected void renderInsertReturningOverwrite(TableDefinition table, JavaWriter out, String reason) { 48 | 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/rx/async/vertx/DefaultSchema.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.rx.async.vertx; 5 | 6 | 7 | import generated.rx.async.vertx.tables.Something; 8 | import generated.rx.async.vertx.tables.Somethingcomposite; 9 | import generated.rx.async.vertx.tables.Somethingwithoutjson; 10 | 11 | import java.util.ArrayList; 12 | import java.util.Arrays; 13 | import java.util.List; 14 | 15 | import javax.annotation.Generated; 16 | 17 | import org.jooq.Catalog; 18 | import org.jooq.Table; 19 | import org.jooq.impl.SchemaImpl; 20 | 21 | 22 | /** 23 | * This class is generated by jOOQ. 24 | */ 25 | @Generated( 26 | value = { 27 | "http://www.jooq.org", 28 | "jOOQ version:3.10.1" 29 | }, 30 | comments = "This class is generated by jOOQ" 31 | ) 32 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 33 | public class DefaultSchema extends SchemaImpl { 34 | 35 | private static final long serialVersionUID = -1561434826; 36 | 37 | /** 38 | * The reference instance of 39 | */ 40 | public static final DefaultSchema DEFAULT_SCHEMA = new DefaultSchema(); 41 | 42 | /** 43 | * The table something. 44 | */ 45 | public final Something SOMETHING = generated.rx.async.vertx.tables.Something.SOMETHING; 46 | 47 | /** 48 | * The table somethingComposite. 49 | */ 50 | public final Somethingcomposite SOMETHINGCOMPOSITE = generated.rx.async.vertx.tables.Somethingcomposite.SOMETHINGCOMPOSITE; 51 | 52 | /** 53 | * The table somethingWithoutJson. 54 | */ 55 | public final Somethingwithoutjson SOMETHINGWITHOUTJSON = generated.rx.async.vertx.tables.Somethingwithoutjson.SOMETHINGWITHOUTJSON; 56 | 57 | /** 58 | * No further instances allowed 59 | */ 60 | private DefaultSchema() { 61 | super("", null); 62 | } 63 | 64 | 65 | /** 66 | * {@inheritDoc} 67 | */ 68 | @Override 69 | public Catalog getCatalog() { 70 | return DefaultCatalog.DEFAULT_CATALOG; 71 | } 72 | 73 | @Override 74 | public final List> getTables() { 75 | List result = new ArrayList(); 76 | result.addAll(getTables0()); 77 | return result; 78 | } 79 | 80 | private final List> getTables0() { 81 | return Arrays.>asList( 82 | Something.SOMETHING, 83 | Somethingcomposite.SOMETHINGCOMPOSITE, 84 | Somethingwithoutjson.SOMETHINGWITHOUTJSON); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/rx/async/vertx/tables/interfaces/ISomethingwithoutjson.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.rx.async.vertx.tables.interfaces; 5 | 6 | 7 | import io.github.jklingsporn.vertx.jooq.async.shared.VertxPojo; 8 | 9 | import java.io.Serializable; 10 | 11 | import javax.annotation.Generated; 12 | 13 | 14 | /** 15 | * This class is generated by jOOQ. 16 | */ 17 | @Generated( 18 | value = { 19 | "http://www.jooq.org", 20 | "jOOQ version:3.10.1" 21 | }, 22 | comments = "This class is generated by jOOQ" 23 | ) 24 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 25 | public interface ISomethingwithoutjson extends VertxPojo, Serializable { 26 | 27 | /** 28 | * Setter for somethingWithoutJson.someId. 29 | */ 30 | public ISomethingwithoutjson setSomeid(Integer value); 31 | 32 | /** 33 | * Getter for somethingWithoutJson.someId. 34 | */ 35 | public Integer getSomeid(); 36 | 37 | /** 38 | * Setter for somethingWithoutJson.someString. 39 | */ 40 | public ISomethingwithoutjson setSomestring(String value); 41 | 42 | /** 43 | * Getter for somethingWithoutJson.someString. 44 | */ 45 | public String getSomestring(); 46 | 47 | // ------------------------------------------------------------------------- 48 | // FROM and INTO 49 | // ------------------------------------------------------------------------- 50 | 51 | /** 52 | * Load data from another generated Record/POJO implementing the common interface ISomethingwithoutjson 53 | */ 54 | public void from(generated.rx.async.vertx.tables.interfaces.ISomethingwithoutjson from); 55 | 56 | /** 57 | * Copy data into another generated Record/POJO implementing the common interface ISomethingwithoutjson 58 | */ 59 | public E into(E into); 60 | 61 | @Override 62 | default ISomethingwithoutjson fromJson(io.vertx.core.json.JsonObject json) { 63 | setSomeid(json.getInteger("someId")); 64 | setSomestring(json.getString("someString")); 65 | return this; 66 | } 67 | 68 | 69 | @Override 70 | default io.vertx.core.json.JsonObject toJson() { 71 | io.vertx.core.json.JsonObject json = new io.vertx.core.json.JsonObject(); 72 | json.put("someId",getSomeid()); 73 | json.put("someString",getSomestring()); 74 | return json; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/future/async/vertx/tables/interfaces/ISomethingwithoutjson.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.future.async.vertx.tables.interfaces; 5 | 6 | 7 | import io.github.jklingsporn.vertx.jooq.async.shared.VertxPojo; 8 | 9 | import java.io.Serializable; 10 | 11 | import javax.annotation.Generated; 12 | 13 | 14 | /** 15 | * This class is generated by jOOQ. 16 | */ 17 | @Generated( 18 | value = { 19 | "http://www.jooq.org", 20 | "jOOQ version:3.10.1" 21 | }, 22 | comments = "This class is generated by jOOQ" 23 | ) 24 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 25 | public interface ISomethingwithoutjson extends VertxPojo, Serializable { 26 | 27 | /** 28 | * Setter for somethingWithoutJson.someId. 29 | */ 30 | public ISomethingwithoutjson setSomeid(Integer value); 31 | 32 | /** 33 | * Getter for somethingWithoutJson.someId. 34 | */ 35 | public Integer getSomeid(); 36 | 37 | /** 38 | * Setter for somethingWithoutJson.someString. 39 | */ 40 | public ISomethingwithoutjson setSomestring(String value); 41 | 42 | /** 43 | * Getter for somethingWithoutJson.someString. 44 | */ 45 | public String getSomestring(); 46 | 47 | // ------------------------------------------------------------------------- 48 | // FROM and INTO 49 | // ------------------------------------------------------------------------- 50 | 51 | /** 52 | * Load data from another generated Record/POJO implementing the common interface ISomethingwithoutjson 53 | */ 54 | public void from(generated.future.async.vertx.tables.interfaces.ISomethingwithoutjson from); 55 | 56 | /** 57 | * Copy data into another generated Record/POJO implementing the common interface ISomethingwithoutjson 58 | */ 59 | public E into(E into); 60 | 61 | @Override 62 | default ISomethingwithoutjson fromJson(io.vertx.core.json.JsonObject json) { 63 | setSomeid(json.getInteger("someId")); 64 | setSomestring(json.getString("someString")); 65 | return this; 66 | } 67 | 68 | 69 | @Override 70 | default io.vertx.core.json.JsonObject toJson() { 71 | io.vertx.core.json.JsonObject json = new io.vertx.core.json.JsonObject(); 72 | json.put("someId",getSomeid()); 73 | json.put("someString",getSomestring()); 74 | return json; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/classic/async/vertx/tables/interfaces/ISomethingwithoutjson.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.classic.async.vertx.tables.interfaces; 5 | 6 | 7 | import io.github.jklingsporn.vertx.jooq.async.shared.VertxPojo; 8 | 9 | import java.io.Serializable; 10 | 11 | import javax.annotation.Generated; 12 | 13 | 14 | /** 15 | * This class is generated by jOOQ. 16 | */ 17 | @Generated( 18 | value = { 19 | "http://www.jooq.org", 20 | "jOOQ version:3.10.1" 21 | }, 22 | comments = "This class is generated by jOOQ" 23 | ) 24 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 25 | public interface ISomethingwithoutjson extends VertxPojo, Serializable { 26 | 27 | /** 28 | * Setter for somethingWithoutJson.someId. 29 | */ 30 | public ISomethingwithoutjson setSomeid(Integer value); 31 | 32 | /** 33 | * Getter for somethingWithoutJson.someId. 34 | */ 35 | public Integer getSomeid(); 36 | 37 | /** 38 | * Setter for somethingWithoutJson.someString. 39 | */ 40 | public ISomethingwithoutjson setSomestring(String value); 41 | 42 | /** 43 | * Getter for somethingWithoutJson.someString. 44 | */ 45 | public String getSomestring(); 46 | 47 | // ------------------------------------------------------------------------- 48 | // FROM and INTO 49 | // ------------------------------------------------------------------------- 50 | 51 | /** 52 | * Load data from another generated Record/POJO implementing the common interface ISomethingwithoutjson 53 | */ 54 | public void from(generated.classic.async.vertx.tables.interfaces.ISomethingwithoutjson from); 55 | 56 | /** 57 | * Copy data into another generated Record/POJO implementing the common interface ISomethingwithoutjson 58 | */ 59 | public E into(E into); 60 | 61 | @Override 62 | default ISomethingwithoutjson fromJson(io.vertx.core.json.JsonObject json) { 63 | setSomeid(json.getInteger("someId")); 64 | setSomestring(json.getString("someString")); 65 | return this; 66 | } 67 | 68 | 69 | @Override 70 | default io.vertx.core.json.JsonObject toJson() { 71 | io.vertx.core.json.JsonObject json = new io.vertx.core.json.JsonObject(); 72 | json.put("someId",getSomeid()); 73 | json.put("someString",getSomestring()); 74 | return json; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/future/async/vertx/DefaultSchema.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.future.async.vertx; 5 | 6 | 7 | import generated.future.async.vertx.tables.Something; 8 | import generated.future.async.vertx.tables.Somethingcomposite; 9 | import generated.future.async.vertx.tables.Somethingwithoutjson; 10 | 11 | import java.util.ArrayList; 12 | import java.util.Arrays; 13 | import java.util.List; 14 | 15 | import javax.annotation.Generated; 16 | 17 | import org.jooq.Catalog; 18 | import org.jooq.Table; 19 | import org.jooq.impl.SchemaImpl; 20 | 21 | 22 | /** 23 | * This class is generated by jOOQ. 24 | */ 25 | @Generated( 26 | value = { 27 | "http://www.jooq.org", 28 | "jOOQ version:3.10.1" 29 | }, 30 | comments = "This class is generated by jOOQ" 31 | ) 32 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 33 | public class DefaultSchema extends SchemaImpl { 34 | 35 | private static final long serialVersionUID = 425802387; 36 | 37 | /** 38 | * The reference instance of 39 | */ 40 | public static final DefaultSchema DEFAULT_SCHEMA = new DefaultSchema(); 41 | 42 | /** 43 | * The table something. 44 | */ 45 | public final Something SOMETHING = generated.future.async.vertx.tables.Something.SOMETHING; 46 | 47 | /** 48 | * The table somethingComposite. 49 | */ 50 | public final Somethingcomposite SOMETHINGCOMPOSITE = generated.future.async.vertx.tables.Somethingcomposite.SOMETHINGCOMPOSITE; 51 | 52 | /** 53 | * The table somethingWithoutJson. 54 | */ 55 | public final Somethingwithoutjson SOMETHINGWITHOUTJSON = generated.future.async.vertx.tables.Somethingwithoutjson.SOMETHINGWITHOUTJSON; 56 | 57 | /** 58 | * No further instances allowed 59 | */ 60 | private DefaultSchema() { 61 | super("", null); 62 | } 63 | 64 | 65 | /** 66 | * {@inheritDoc} 67 | */ 68 | @Override 69 | public Catalog getCatalog() { 70 | return DefaultCatalog.DEFAULT_CATALOG; 71 | } 72 | 73 | @Override 74 | public final List> getTables() { 75 | List result = new ArrayList(); 76 | result.addAll(getTables0()); 77 | return result; 78 | } 79 | 80 | private final List> getTables0() { 81 | return Arrays.>asList( 82 | Something.SOMETHING, 83 | Somethingcomposite.SOMETHINGCOMPOSITE, 84 | Somethingwithoutjson.SOMETHINGWITHOUTJSON); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/classic/async/vertx/DefaultSchema.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.classic.async.vertx; 5 | 6 | 7 | import generated.classic.async.vertx.tables.Something; 8 | import generated.classic.async.vertx.tables.Somethingcomposite; 9 | import generated.classic.async.vertx.tables.Somethingwithoutjson; 10 | 11 | import java.util.ArrayList; 12 | import java.util.Arrays; 13 | import java.util.List; 14 | 15 | import javax.annotation.Generated; 16 | 17 | import org.jooq.Catalog; 18 | import org.jooq.Table; 19 | import org.jooq.impl.SchemaImpl; 20 | 21 | 22 | /** 23 | * This class is generated by jOOQ. 24 | */ 25 | @Generated( 26 | value = { 27 | "http://www.jooq.org", 28 | "jOOQ version:3.10.1" 29 | }, 30 | comments = "This class is generated by jOOQ" 31 | ) 32 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 33 | public class DefaultSchema extends SchemaImpl { 34 | 35 | private static final long serialVersionUID = -1525087410; 36 | 37 | /** 38 | * The reference instance of 39 | */ 40 | public static final DefaultSchema DEFAULT_SCHEMA = new DefaultSchema(); 41 | 42 | /** 43 | * The table something. 44 | */ 45 | public final Something SOMETHING = generated.classic.async.vertx.tables.Something.SOMETHING; 46 | 47 | /** 48 | * The table somethingComposite. 49 | */ 50 | public final Somethingcomposite SOMETHINGCOMPOSITE = generated.classic.async.vertx.tables.Somethingcomposite.SOMETHINGCOMPOSITE; 51 | 52 | /** 53 | * The table somethingWithoutJson. 54 | */ 55 | public final Somethingwithoutjson SOMETHINGWITHOUTJSON = generated.classic.async.vertx.tables.Somethingwithoutjson.SOMETHINGWITHOUTJSON; 56 | 57 | /** 58 | * No further instances allowed 59 | */ 60 | private DefaultSchema() { 61 | super("", null); 62 | } 63 | 64 | 65 | /** 66 | * {@inheritDoc} 67 | */ 68 | @Override 69 | public Catalog getCatalog() { 70 | return DefaultCatalog.DEFAULT_CATALOG; 71 | } 72 | 73 | @Override 74 | public final List> getTables() { 75 | List result = new ArrayList(); 76 | result.addAll(getTables0()); 77 | return result; 78 | } 79 | 80 | private final List> getTables0() { 81 | return Arrays.>asList( 82 | Something.SOMETHING, 83 | Somethingcomposite.SOMETHINGCOMPOSITE, 84 | Somethingwithoutjson.SOMETHINGWITHOUTJSON); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/io/github/jklingsporn/vertx/jooq/async/generate/classic/VertxSomethingCompositeDaoTest.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.generate.classic; 2 | 3 | import generated.classic.async.vertx.tables.pojos.Somethingcomposite; 4 | import generated.classic.async.vertx.tables.records.SomethingcompositeRecord; 5 | import io.vertx.core.json.JsonObject; 6 | import org.junit.Assert; 7 | import org.junit.Test; 8 | 9 | import java.util.concurrent.CountDownLatch; 10 | 11 | /** 12 | * Created by jensklingsporn on 02.11.16. 13 | */ 14 | public class VertxSomethingCompositeDaoTest extends VertxDaoTestBase { 15 | 16 | 17 | @Test 18 | public void asyncCRUDExecShouldSucceed() throws InterruptedException { 19 | CountDownLatch latch = new CountDownLatch(1); 20 | Somethingcomposite something = createSomething(1, 1); 21 | compositeDao.insertExecAsync(something, consumeOrFailHandler(key->{ 22 | Assert.assertEquals(1l,key.longValue()); 23 | something.getSomejsonobject().put("foo","bar"); 24 | compositeDao.updateExecAsync(something, 25 | consumeOrFailHandler(updatedRows -> { 26 | Assert.assertEquals(1l, updatedRows.longValue()); 27 | SomethingcompositeRecord somethingcompositeRecord = new SomethingcompositeRecord(); 28 | somethingcompositeRecord.from(something); 29 | compositeDao.deleteExecAsync(somethingcompositeRecord.key(), deletedRows -> { 30 | if (deletedRows.failed()) { 31 | Assert.fail(deletedRows.cause().getMessage()); 32 | } else { 33 | Assert.assertEquals(1l, deletedRows.result().longValue()); 34 | } 35 | latch.countDown(); 36 | }); 37 | }) 38 | ); 39 | })); 40 | await(latch); 41 | } 42 | 43 | @Test(expected = UnsupportedOperationException.class) 44 | public void insertReturningShouldFailForCompositePK(){ 45 | compositeDao.insertReturningPrimaryAsync(createSomething(0,0), f->{}); 46 | } 47 | 48 | 49 | private Somethingcomposite createSomething(int someId, int someSecondId){ 50 | Somethingcomposite something = new Somethingcomposite(); 51 | something.setSomeid(someId); 52 | something.setSomesecondid(someSecondId); 53 | something.setSomejsonobject(new JsonObject().put("key", "value")); 54 | return something; 55 | } 56 | 57 | 58 | } 59 | -------------------------------------------------------------------------------- /vertx-jooq-async-rx/src/test/java/io/github/jklingsporn/vertx/jooq/async/rx/util/RXToolTest.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.rx.util; 2 | 3 | import io.vertx.reactivex.core.Vertx; 4 | import org.junit.After; 5 | import org.junit.Before; 6 | import org.junit.Test; 7 | 8 | import java.util.Arrays; 9 | import java.util.concurrent.CountDownLatch; 10 | import java.util.concurrent.TimeUnit; 11 | 12 | /** 13 | * @author Clement Escoffier 14 | */ 15 | public class RXToolTest { 16 | 17 | private Vertx vertx; 18 | 19 | @Before 20 | public void setUp() { 21 | vertx = Vertx.vertx(); 22 | } 23 | 24 | @After 25 | public void tearDown() { 26 | vertx.close(); 27 | } 28 | 29 | @Test 30 | public void executeBlockingShouldCompleteSingle() throws InterruptedException { 31 | CountDownLatch countDownLatch = new CountDownLatch(1); 32 | RXTool.executeBlocking(h -> { 33 | }, vertx) 34 | .subscribe(v -> countDownLatch.countDown()); 35 | countDownLatch.await(1, TimeUnit.SECONDS); 36 | } 37 | 38 | @Test 39 | public void executeBlockingObservableShouldExecuteOnNextAndOnComplete() throws InterruptedException { 40 | CountDownLatch countDownLatch = new CountDownLatch(4); 41 | CountDownLatch countDownLatchCompletion = new CountDownLatch(1); 42 | RXTool.executeBlockingObservable(h -> h.complete(Arrays.asList(1, 2, 3, 4)), vertx) 43 | .subscribe( 44 | i -> countDownLatch.countDown(), 45 | t -> { 46 | throw new RuntimeException(t); 47 | }, 48 | countDownLatchCompletion::countDown 49 | ); 50 | countDownLatch.await(1, TimeUnit.SECONDS); 51 | countDownLatchCompletion.await(1, TimeUnit.SECONDS); 52 | } 53 | 54 | @Test 55 | public void executeBlockingShouldFailSingleOnException() throws InterruptedException { 56 | CountDownLatch countDownLatch = new CountDownLatch(1); 57 | RXTool.executeBlocking(h -> { 58 | throw new RuntimeException("Expected"); 59 | }, vertx) 60 | .subscribe( 61 | v -> { 62 | throw new RuntimeException("Should not be called"); 63 | }, 64 | t -> countDownLatch.countDown()); 65 | countDownLatch.await(1, TimeUnit.SECONDS); 66 | } 67 | 68 | @Test 69 | public void executeBlockingShouldFailSingleOnFailure() throws InterruptedException { 70 | CountDownLatch countDownLatch = new CountDownLatch(1); 71 | RXTool.executeBlocking(h -> h.fail("Expected"), vertx) 72 | .subscribe( 73 | v -> { 74 | throw new RuntimeException("Should not be called"); 75 | }, 76 | t -> countDownLatch.countDown()); 77 | countDownLatch.await(1, TimeUnit.SECONDS); 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/rx/async/vertx/tables/interfaces/ISomethingcomposite.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.rx.async.vertx.tables.interfaces; 5 | 6 | 7 | import io.github.jklingsporn.vertx.jooq.async.shared.VertxPojo; 8 | import io.vertx.core.json.JsonObject; 9 | 10 | import java.io.Serializable; 11 | 12 | import javax.annotation.Generated; 13 | 14 | 15 | /** 16 | * This class is generated by jOOQ. 17 | */ 18 | @Generated( 19 | value = { 20 | "http://www.jooq.org", 21 | "jOOQ version:3.10.1" 22 | }, 23 | comments = "This class is generated by jOOQ" 24 | ) 25 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 26 | public interface ISomethingcomposite extends VertxPojo, Serializable { 27 | 28 | /** 29 | * Setter for somethingComposite.someId. 30 | */ 31 | public ISomethingcomposite setSomeid(Integer value); 32 | 33 | /** 34 | * Getter for somethingComposite.someId. 35 | */ 36 | public Integer getSomeid(); 37 | 38 | /** 39 | * Setter for somethingComposite.someSecondId. 40 | */ 41 | public ISomethingcomposite setSomesecondid(Integer value); 42 | 43 | /** 44 | * Getter for somethingComposite.someSecondId. 45 | */ 46 | public Integer getSomesecondid(); 47 | 48 | /** 49 | * Setter for somethingComposite.someJsonObject. 50 | */ 51 | public ISomethingcomposite setSomejsonobject(JsonObject value); 52 | 53 | /** 54 | * Getter for somethingComposite.someJsonObject. 55 | */ 56 | public JsonObject getSomejsonobject(); 57 | 58 | // ------------------------------------------------------------------------- 59 | // FROM and INTO 60 | // ------------------------------------------------------------------------- 61 | 62 | /** 63 | * Load data from another generated Record/POJO implementing the common interface ISomethingcomposite 64 | */ 65 | public void from(generated.rx.async.vertx.tables.interfaces.ISomethingcomposite from); 66 | 67 | /** 68 | * Copy data into another generated Record/POJO implementing the common interface ISomethingcomposite 69 | */ 70 | public E into(E into); 71 | 72 | @Override 73 | default ISomethingcomposite fromJson(io.vertx.core.json.JsonObject json) { 74 | setSomeid(json.getInteger("someId")); 75 | setSomesecondid(json.getInteger("someSecondId")); 76 | setSomejsonobject(json.getJsonObject("someJsonObject")); 77 | return this; 78 | } 79 | 80 | 81 | @Override 82 | default io.vertx.core.json.JsonObject toJson() { 83 | io.vertx.core.json.JsonObject json = new io.vertx.core.json.JsonObject(); 84 | json.put("someId",getSomeid()); 85 | json.put("someSecondId",getSomesecondid()); 86 | json.put("someJsonObject",getSomejsonobject()); 87 | return json; 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/classic/async/vertx/tables/interfaces/ISomethingcomposite.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.classic.async.vertx.tables.interfaces; 5 | 6 | 7 | import io.github.jklingsporn.vertx.jooq.async.shared.VertxPojo; 8 | import io.vertx.core.json.JsonObject; 9 | 10 | import java.io.Serializable; 11 | 12 | import javax.annotation.Generated; 13 | 14 | 15 | /** 16 | * This class is generated by jOOQ. 17 | */ 18 | @Generated( 19 | value = { 20 | "http://www.jooq.org", 21 | "jOOQ version:3.10.1" 22 | }, 23 | comments = "This class is generated by jOOQ" 24 | ) 25 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 26 | public interface ISomethingcomposite extends VertxPojo, Serializable { 27 | 28 | /** 29 | * Setter for somethingComposite.someId. 30 | */ 31 | public ISomethingcomposite setSomeid(Integer value); 32 | 33 | /** 34 | * Getter for somethingComposite.someId. 35 | */ 36 | public Integer getSomeid(); 37 | 38 | /** 39 | * Setter for somethingComposite.someSecondId. 40 | */ 41 | public ISomethingcomposite setSomesecondid(Integer value); 42 | 43 | /** 44 | * Getter for somethingComposite.someSecondId. 45 | */ 46 | public Integer getSomesecondid(); 47 | 48 | /** 49 | * Setter for somethingComposite.someJsonObject. 50 | */ 51 | public ISomethingcomposite setSomejsonobject(JsonObject value); 52 | 53 | /** 54 | * Getter for somethingComposite.someJsonObject. 55 | */ 56 | public JsonObject getSomejsonobject(); 57 | 58 | // ------------------------------------------------------------------------- 59 | // FROM and INTO 60 | // ------------------------------------------------------------------------- 61 | 62 | /** 63 | * Load data from another generated Record/POJO implementing the common interface ISomethingcomposite 64 | */ 65 | public void from(generated.classic.async.vertx.tables.interfaces.ISomethingcomposite from); 66 | 67 | /** 68 | * Copy data into another generated Record/POJO implementing the common interface ISomethingcomposite 69 | */ 70 | public E into(E into); 71 | 72 | @Override 73 | default ISomethingcomposite fromJson(io.vertx.core.json.JsonObject json) { 74 | setSomeid(json.getInteger("someId")); 75 | setSomesecondid(json.getInteger("someSecondId")); 76 | setSomejsonobject(json.getJsonObject("someJsonObject")); 77 | return this; 78 | } 79 | 80 | 81 | @Override 82 | default io.vertx.core.json.JsonObject toJson() { 83 | io.vertx.core.json.JsonObject json = new io.vertx.core.json.JsonObject(); 84 | json.put("someId",getSomeid()); 85 | json.put("someSecondId",getSomesecondid()); 86 | json.put("someJsonObject",getSomejsonobject()); 87 | return json; 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/future/async/vertx/tables/interfaces/ISomethingcomposite.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.future.async.vertx.tables.interfaces; 5 | 6 | 7 | import io.github.jklingsporn.vertx.jooq.async.shared.VertxPojo; 8 | import io.vertx.core.json.JsonObject; 9 | 10 | import java.io.Serializable; 11 | 12 | import javax.annotation.Generated; 13 | 14 | 15 | /** 16 | * This class is generated by jOOQ. 17 | */ 18 | @Generated( 19 | value = { 20 | "http://www.jooq.org", 21 | "jOOQ version:3.10.1" 22 | }, 23 | comments = "This class is generated by jOOQ" 24 | ) 25 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 26 | public interface ISomethingcomposite extends VertxPojo, Serializable { 27 | 28 | /** 29 | * Setter for somethingComposite.someId. 30 | */ 31 | public ISomethingcomposite setSomeid(Integer value); 32 | 33 | /** 34 | * Getter for somethingComposite.someId. 35 | */ 36 | public Integer getSomeid(); 37 | 38 | /** 39 | * Setter for somethingComposite.someSecondId. 40 | */ 41 | public ISomethingcomposite setSomesecondid(Integer value); 42 | 43 | /** 44 | * Getter for somethingComposite.someSecondId. 45 | */ 46 | public Integer getSomesecondid(); 47 | 48 | /** 49 | * Setter for somethingComposite.someJsonObject. 50 | */ 51 | public ISomethingcomposite setSomejsonobject(JsonObject value); 52 | 53 | /** 54 | * Getter for somethingComposite.someJsonObject. 55 | */ 56 | public JsonObject getSomejsonobject(); 57 | 58 | // ------------------------------------------------------------------------- 59 | // FROM and INTO 60 | // ------------------------------------------------------------------------- 61 | 62 | /** 63 | * Load data from another generated Record/POJO implementing the common interface ISomethingcomposite 64 | */ 65 | public void from(generated.future.async.vertx.tables.interfaces.ISomethingcomposite from); 66 | 67 | /** 68 | * Copy data into another generated Record/POJO implementing the common interface ISomethingcomposite 69 | */ 70 | public E into(E into); 71 | 72 | @Override 73 | default ISomethingcomposite fromJson(io.vertx.core.json.JsonObject json) { 74 | setSomeid(json.getInteger("someId")); 75 | setSomesecondid(json.getInteger("someSecondId")); 76 | setSomejsonobject(json.getJsonObject("someJsonObject")); 77 | return this; 78 | } 79 | 80 | 81 | @Override 82 | default io.vertx.core.json.JsonObject toJson() { 83 | io.vertx.core.json.JsonObject json = new io.vertx.core.json.JsonObject(); 84 | json.put("someId",getSomeid()); 85 | json.put("someSecondId",getSomesecondid()); 86 | json.put("someJsonObject",getSomejsonobject()); 87 | return json; 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/main/java/io/github/jklingsporn/vertx/jooq/async/generate/classic/ClassicAsyncVertxGuiceGenerator.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.generate.classic; 2 | 3 | import io.github.jklingsporn.vertx.jooq.async.generate.AbstractVertxGuiceGenerator; 4 | import org.jooq.util.GeneratorStrategy; 5 | import org.jooq.util.JavaWriter; 6 | import org.jooq.util.TableDefinition; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Created by jensklingsporn on 19.04.17. 12 | */ 13 | public class ClassicAsyncVertxGuiceGenerator extends AbstractVertxGuiceGenerator { 14 | 15 | public ClassicAsyncVertxGuiceGenerator() { 16 | super(ClassicAsyncVertxGenerator.VERTX_DAO_NAME); 17 | } 18 | 19 | public ClassicAsyncVertxGuiceGenerator(boolean generateJson, boolean generateGuiceModules, boolean generateInjectConfigurationMethod) { 20 | super(ClassicAsyncVertxGenerator.VERTX_DAO_NAME, generateJson, generateGuiceModules, generateInjectConfigurationMethod); 21 | } 22 | 23 | @Override 24 | protected void generateDAOImports(JavaWriter out) { 25 | out.println("import io.vertx.core.Handler;"); 26 | out.println("import io.vertx.core.AsyncResult;"); 27 | } 28 | 29 | @Override 30 | protected void renderInsertReturningOverwrite(TableDefinition table, JavaWriter out, String reason) { 31 | out.println(); 32 | out.tab(1).println("@Override"); 33 | out.tab(1).println("public void insertReturningPrimaryAsync(%s object, Handler> resultHandler){", 34 | out.ref(getStrategy().getFullJavaClassName(table, GeneratorStrategy.Mode.POJO)), 35 | getKeyType(table.getPrimaryKey())); 36 | out.tab(2).println("throw new UnsupportedOperationException(\"%s\");",reason); 37 | out.tab(1).println("}"); 38 | out.println(); 39 | } 40 | 41 | @Override 42 | protected void generateFetchOneByMethods(JavaWriter out, String pType, String colName, String colClass, String colType, String colIdentifier) { 43 | out.tab(1).javadoc("Fetch a unique record that has %s = value asynchronously", colName); 44 | 45 | out.tab(1).println("public void fetchOneBy%sAsync(%s value,Handler> resultHandler) {", colClass, colType,pType); 46 | out.tab(2).println("vertx().executeBlocking(h->h.complete(fetchOneBy%s(value)),resultHandler);", colClass); 47 | out.tab(1).println("}"); 48 | } 49 | 50 | @Override 51 | protected void generateFetchByMethods(JavaWriter out, String pType, String colName, String colClass, String colType, String colIdentifier) { 52 | out.tab(1).javadoc("Fetch records that have %s IN (values) asynchronously", colName); 53 | out.tab(1).println("public void fetchBy%sAsync(%s<%s> values,Handler>> resultHandler) {", colClass, List.class, colType,pType); 54 | //out.tab(2).println("return fetch(%s, values);", colIdentifier); 55 | out.tab(2).println("fetchAsync(%s,values,resultHandler);", colIdentifier); 56 | out.tab(1).println("}"); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/io/github/jklingsporn/vertx/jooq/async/generate/future/VertxDaoTestBase.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.generate.future; 2 | 3 | import generated.future.async.vertx.tables.daos.SomethingDao; 4 | import generated.future.async.vertx.tables.daos.SomethingcompositeDao; 5 | import io.github.jklingsporn.vertx.jooq.async.future.AsyncJooqSQLClient; 6 | import io.github.jklingsporn.vertx.jooq.async.generate.TestTool; 7 | import io.vertx.core.Vertx; 8 | import io.vertx.core.json.JsonObject; 9 | import io.vertx.ext.asyncsql.MySQLClient; 10 | import org.jooq.Configuration; 11 | import org.jooq.SQLDialect; 12 | import org.jooq.impl.DefaultConfiguration; 13 | import org.junit.Assert; 14 | import org.junit.BeforeClass; 15 | import org.slf4j.Logger; 16 | import org.slf4j.LoggerFactory; 17 | 18 | import java.sql.SQLException; 19 | import java.util.concurrent.CompletableFuture; 20 | import java.util.concurrent.CountDownLatch; 21 | import java.util.concurrent.TimeUnit; 22 | import java.util.function.BiConsumer; 23 | 24 | /** 25 | * Created by jensklingsporn on 07.11.16. 26 | */ 27 | public class VertxDaoTestBase { 28 | 29 | private static final Logger logger = LoggerFactory.getLogger(VertxDaoTestBase.class); 30 | 31 | protected static SomethingDao dao; 32 | protected static SomethingcompositeDao compositeDao; 33 | 34 | @BeforeClass 35 | public static void beforeClass() throws SQLException { 36 | TestTool.setupDB(); 37 | Configuration configuration = new DefaultConfiguration(); 38 | configuration.set(SQLDialect.MYSQL); 39 | 40 | JsonObject config = new JsonObject().put("host", "127.0.0.1").put("username", "vertx").putNull("password").put("database","vertx"); 41 | dao = new SomethingDao(configuration); 42 | Vertx vertx = Vertx.vertx(); 43 | dao.setClient(AsyncJooqSQLClient.create(vertx,MySQLClient.createNonShared(vertx, config))); 44 | 45 | compositeDao = new SomethingcompositeDao(configuration); 46 | compositeDao.setClient(AsyncJooqSQLClient.create(vertx,MySQLClient.createNonShared(vertx, config))); 47 | } 48 | 49 | protected void await(CountDownLatch latch) { 50 | try { 51 | if(!latch.await(3, TimeUnit.SECONDS)){ 52 | Assert.fail("latch not triggered"); 53 | } 54 | } catch (InterruptedException e) { 55 | Assert.fail(e.getMessage()); 56 | } 57 | } 58 | 59 | protected void assertFutureCompleted(CompletableFuture cf){ 60 | Assert.assertTrue(cf.isDone()); 61 | Assert.assertFalse(cf.isCompletedExceptionally()); 62 | } 63 | 64 | 65 | protected BiConsumer failOnException(){ 66 | return (t,x)->{ 67 | if(x!=null){ 68 | Assert.fail(x.getMessage()); 69 | } 70 | }; 71 | } 72 | 73 | protected BiConsumer failOrCountDown(CountDownLatch latch){ 74 | return (t,x)->{ 75 | if(x!=null){ 76 | logger.error(x.getMessage(),x); 77 | Assert.fail(x.getMessage()); 78 | }else{ 79 | latch.countDown(); 80 | } 81 | }; 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/io/github/jklingsporn/vertx/jooq/async/generate/rx/VertxSomethingCompositeDaoTest.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.generate.rx; 2 | 3 | import generated.rx.async.vertx.tables.pojos.Somethingcomposite; 4 | import generated.rx.async.vertx.tables.records.SomethingcompositeRecord; 5 | import io.vertx.core.json.JsonObject; 6 | import org.junit.Assert; 7 | import org.junit.Test; 8 | 9 | import java.util.concurrent.CountDownLatch; 10 | 11 | /** 12 | * @author Clement Escoffier 13 | * @author Jens Klingsporn 14 | */ 15 | public class VertxSomethingCompositeDaoTest extends RXVertxDaoTestBase { 16 | 17 | 18 | @Test 19 | public void asyncCRUDShouldSucceed() throws InterruptedException { 20 | CountDownLatch latch = new CountDownLatch(1); 21 | Somethingcomposite something = createSomething(0, 0); 22 | SomethingcompositeRecord somethingcompositeRecord = new SomethingcompositeRecord(); 23 | somethingcompositeRecord.from(something); 24 | compositeDao.insertExecAsync(something). 25 | flatMap( 26 | v-> compositeDao.findByIdAsync(somethingcompositeRecord.key())). 27 | flatMap(fetchSomething -> { 28 | fetchSomething.getSomejsonobject().put("foo", "bar"); 29 | return compositeDao.updateExecAsync(fetchSomething); 30 | }). 31 | flatMap(v2->compositeDao.deleteExecAsync(somethingcompositeRecord.key())). 32 | subscribe(failOrCountDownSingleObserver(latch)); 33 | await(latch); 34 | } 35 | 36 | 37 | @Test 38 | public void asyncCRUDExecShouldSucceed() throws InterruptedException { 39 | CountDownLatch latch = new CountDownLatch(1); 40 | Somethingcomposite something = createSomething(1, 1); 41 | SomethingcompositeRecord somethingcompositeRecord = new SomethingcompositeRecord(); 42 | somethingcompositeRecord.from(something); 43 | compositeDao.insertExecAsync(something). 44 | flatMap( 45 | inserted-> { 46 | Assert.assertEquals(1L, inserted.longValue()); 47 | return compositeDao.findByIdAsync(somethingcompositeRecord.key()); 48 | }). 49 | flatMap(fetchSomething -> { 50 | fetchSomething.getSomejsonobject().put("foo", "bar"); 51 | return compositeDao.updateExecAsync(fetchSomething); 52 | }). 53 | doOnSuccess(updated -> Assert.assertEquals(1L, updated.longValue())). 54 | flatMap(v -> compositeDao.deleteExecAsync(somethingcompositeRecord.key())). 55 | subscribe(failOrCountDownSingleObserver(latch)); 56 | await(latch); 57 | } 58 | 59 | private Somethingcomposite createSomething(int someId, int someSecondId) { 60 | Somethingcomposite something = new Somethingcomposite(); 61 | something.setSomejsonobject(new JsonObject().put("key", "value")); 62 | something.setSomeid(someId); 63 | something.setSomesecondid(someSecondId); 64 | return something; 65 | } 66 | 67 | 68 | } 69 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/main/java/io/github/jklingsporn/vertx/jooq/async/generate/future/FutureAsyncVertxGenerator.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.generate.future; 2 | 3 | import io.github.jklingsporn.vertx.jooq.async.generate.AbstractVertxGenerator; 4 | import org.jooq.util.JavaWriter; 5 | import org.jooq.util.TableDefinition; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by jensklingsporn on 19.04.17. 11 | */ 12 | public class FutureAsyncVertxGenerator extends AbstractVertxGenerator { 13 | 14 | public static final String VERTX_DAO_NAME = "io.github.jklingsporn.vertx.jooq.async.future.VertxDAO"; 15 | 16 | @Override 17 | protected void generateDAOImports(JavaWriter out) { 18 | out.println("import java.util.concurrent.CompletableFuture;"); 19 | out.println("import io.github.jklingsporn.vertx.jooq.async.future.AsyncJooqSQLClient;"); 20 | } 21 | 22 | @Override 23 | protected void generateFetchOneByMethods(JavaWriter out, String pType, String colName, String colClass, String colType, String colIdentifier) { 24 | out.tab(1).javadoc("Fetch a unique record that has %s = value asynchronously", colName); 25 | 26 | out.tab(1).println("public CompletableFuture<%s> fetchOneBy%sAsync(%s value) {", pType,colClass, colType); 27 | out.tab(2).println("return fetchOneAsync(%s,value);", colIdentifier); 28 | out.tab(1).println("}"); 29 | } 30 | 31 | @Override 32 | protected void generateFetchByMethods(JavaWriter out, String pType, String colName, String colClass, String colType, String colIdentifier) { 33 | out.tab(1).javadoc("Fetch records that have %s IN (values) asynchronously", colName); 34 | out.tab(1).println("public CompletableFuture> fetchBy%sAsync(%s<%s> values) {", pType, colClass, List.class, colType); 35 | //out.tab(2).println("return fetch(%s, values);", colIdentifier); 36 | out.tab(2).println("return fetchAsync(%s,values);", colIdentifier); 37 | out.tab(1).println("}"); 38 | } 39 | 40 | @Override 41 | protected void generateVertxGetterAndSetterConfigurationMethod(JavaWriter out) { 42 | //noop 43 | } 44 | 45 | @Override 46 | protected void renderInsertReturningOverwrite(TableDefinition table, JavaWriter out, String reason) { 47 | 48 | } 49 | 50 | @Override 51 | protected void generateDaoClassFooter(TableDefinition table, JavaWriter out) { 52 | super.generateDaoClassFooter(table, out); 53 | generateClientGetterAndSetter(out); 54 | generateJsonMapper(table,out); 55 | } 56 | 57 | protected void generateClientGetterAndSetter(JavaWriter out) { 58 | out.println(); 59 | out.tab(1).println("private AsyncJooqSQLClient client;"); 60 | out.println(); 61 | generateSetVertxAnnotation(out); 62 | out.tab(1).println("@Override"); 63 | out.tab(1).println("public void setClient(AsyncJooqSQLClient client) {"); 64 | out.tab(2).println("this.client = client;"); 65 | out.tab(1).println("}"); 66 | out.println(); 67 | out.tab(1).println("@Override"); 68 | out.tab(1).println("public AsyncJooqSQLClient client() {"); 69 | out.tab(2).println("return this.client;"); 70 | out.tab(1).println("}"); 71 | out.println(); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/main/java/io/github/jklingsporn/vertx/jooq/async/generate/rx/RXAsyncVertxGenerator.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.generate.rx; 2 | 3 | import io.github.jklingsporn.vertx.jooq.async.generate.AbstractVertxGenerator; 4 | import org.jooq.util.JavaWriter; 5 | import org.jooq.util.TableDefinition; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author Clement Escoffier 11 | */ 12 | public class RXAsyncVertxGenerator extends AbstractVertxGenerator { 13 | 14 | public static final String VERTX_DAO_NAME = "io.github.jklingsporn.vertx.jooq.async.rx.VertxDAO"; 15 | 16 | @Override 17 | protected void generateDAOImports(JavaWriter out) { 18 | out.println("import io.reactivex.Completable;"); 19 | out.println("import io.reactivex.Observable;"); 20 | out.println("import io.reactivex.Single;"); 21 | out.println("import io.github.jklingsporn.vertx.jooq.async.rx.util.RXTool;"); 22 | out.println("import io.github.jklingsporn.vertx.jooq.async.rx.AsyncJooqSQLClient;"); 23 | } 24 | 25 | @Override 26 | protected void generateFetchOneByMethods(JavaWriter out, String pType, String colName, String colClass, String colType, String colIdentifier) { 27 | out.tab(1).javadoc("Fetch a unique record that has %s = value asynchronously", colName); 28 | 29 | out.tab(1).println("public Single<%s> fetchOneBy%sAsync(%s value) {", pType,colClass, colType); 30 | out.tab(2).println("return fetchOneAsync(%s,value);", colIdentifier); 31 | out.tab(1).println("}"); 32 | } 33 | 34 | @Override 35 | protected void generateFetchByMethods(JavaWriter out, String pType, String colName, String colClass, String colType, String colIdentifier) { 36 | out.tab(1).javadoc("Fetch records that have %s IN (values) asynchronously", colName); 37 | out.tab(1).println("public Single> fetchBy%sAsync(%s<%s> values) {", pType, colClass, List.class, 38 | colType); 39 | out.tab(2).println("return fetchAsync(%s,values);", colIdentifier); 40 | out.tab(1).println("}"); 41 | 42 | out.tab(1).javadoc("Fetch records that have %s IN (values) asynchronously", colName); 43 | out.tab(1).println("public Observable<%s> fetchBy%sObservable(%s<%s> values) {", pType, colClass, List.class, colType); 44 | out.tab(2).println("return fetchObservable(%s,values);", colIdentifier); 45 | out.tab(1).println("}"); 46 | } 47 | 48 | @Override 49 | protected void generateVertxGetterAndSetterConfigurationMethod(JavaWriter out) { 50 | //noop 51 | } 52 | 53 | @Override 54 | protected void generateDaoClassFooter(TableDefinition table, JavaWriter out) { 55 | super.generateDaoClassFooter(table, out); 56 | generateClientGetterAndSetter(out); 57 | generateJsonMapper(table,out); 58 | } 59 | 60 | protected void generateClientGetterAndSetter(JavaWriter out) { 61 | out.println(); 62 | out.tab(1).println("private AsyncJooqSQLClient client;"); 63 | out.println(); 64 | generateSetVertxAnnotation(out); 65 | out.tab(1).println("@Override"); 66 | out.tab(1).println("public void setClient(AsyncJooqSQLClient client) {"); 67 | out.tab(2).println("this.client = client;"); 68 | out.tab(1).println("}"); 69 | out.println(); 70 | out.tab(1).println("@Override"); 71 | out.tab(1).println("public AsyncJooqSQLClient client() {"); 72 | out.tab(2).println("return this.client;"); 73 | out.tab(1).println("}"); 74 | out.println(); 75 | } 76 | 77 | @Override 78 | protected void renderInsertReturningOverwrite(TableDefinition table, JavaWriter out, String reason) { 79 | 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/rx/async/vertx/Keys.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.rx.async.vertx; 5 | 6 | 7 | import generated.rx.async.vertx.tables.Something; 8 | import generated.rx.async.vertx.tables.Somethingcomposite; 9 | import generated.rx.async.vertx.tables.Somethingwithoutjson; 10 | import generated.rx.async.vertx.tables.records.SomethingRecord; 11 | import generated.rx.async.vertx.tables.records.SomethingcompositeRecord; 12 | import generated.rx.async.vertx.tables.records.SomethingwithoutjsonRecord; 13 | 14 | import javax.annotation.Generated; 15 | 16 | import org.jooq.Identity; 17 | import org.jooq.UniqueKey; 18 | import org.jooq.impl.AbstractKeys; 19 | 20 | 21 | /** 22 | * A class modelling foreign key relationships and constraints of tables of 23 | * the schema. 24 | */ 25 | @Generated( 26 | value = { 27 | "http://www.jooq.org", 28 | "jOOQ version:3.10.1" 29 | }, 30 | comments = "This class is generated by jOOQ" 31 | ) 32 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 33 | public class Keys { 34 | 35 | // ------------------------------------------------------------------------- 36 | // IDENTITY definitions 37 | // ------------------------------------------------------------------------- 38 | 39 | public static final Identity IDENTITY_SOMETHING = Identities0.IDENTITY_SOMETHING; 40 | public static final Identity IDENTITY_SOMETHINGWITHOUTJSON = Identities0.IDENTITY_SOMETHINGWITHOUTJSON; 41 | 42 | // ------------------------------------------------------------------------- 43 | // UNIQUE and PRIMARY KEY definitions 44 | // ------------------------------------------------------------------------- 45 | 46 | public static final UniqueKey KEY_SOMETHING_PRIMARY = UniqueKeys0.KEY_SOMETHING_PRIMARY; 47 | public static final UniqueKey KEY_SOMETHINGCOMPOSITE_PRIMARY = UniqueKeys0.KEY_SOMETHINGCOMPOSITE_PRIMARY; 48 | public static final UniqueKey KEY_SOMETHINGWITHOUTJSON_PRIMARY = UniqueKeys0.KEY_SOMETHINGWITHOUTJSON_PRIMARY; 49 | 50 | // ------------------------------------------------------------------------- 51 | // FOREIGN KEY definitions 52 | // ------------------------------------------------------------------------- 53 | 54 | 55 | // ------------------------------------------------------------------------- 56 | // [#1459] distribute members to avoid static initialisers > 64kb 57 | // ------------------------------------------------------------------------- 58 | 59 | private static class Identities0 extends AbstractKeys { 60 | public static Identity IDENTITY_SOMETHING = createIdentity(Something.SOMETHING, Something.SOMETHING.SOMEID); 61 | public static Identity IDENTITY_SOMETHINGWITHOUTJSON = createIdentity(Somethingwithoutjson.SOMETHINGWITHOUTJSON, Somethingwithoutjson.SOMETHINGWITHOUTJSON.SOMEID); 62 | } 63 | 64 | private static class UniqueKeys0 extends AbstractKeys { 65 | public static final UniqueKey KEY_SOMETHING_PRIMARY = createUniqueKey(Something.SOMETHING, "KEY_something_PRIMARY", Something.SOMETHING.SOMEID); 66 | public static final UniqueKey KEY_SOMETHINGCOMPOSITE_PRIMARY = createUniqueKey(Somethingcomposite.SOMETHINGCOMPOSITE, "KEY_somethingComposite_PRIMARY", Somethingcomposite.SOMETHINGCOMPOSITE.SOMEID, Somethingcomposite.SOMETHINGCOMPOSITE.SOMESECONDID); 67 | public static final UniqueKey KEY_SOMETHINGWITHOUTJSON_PRIMARY = createUniqueKey(Somethingwithoutjson.SOMETHINGWITHOUTJSON, "KEY_somethingWithoutJson_PRIMARY", Somethingwithoutjson.SOMETHINGWITHOUTJSON.SOMEID); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/future/async/vertx/Keys.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.future.async.vertx; 5 | 6 | 7 | import generated.future.async.vertx.tables.Something; 8 | import generated.future.async.vertx.tables.Somethingcomposite; 9 | import generated.future.async.vertx.tables.Somethingwithoutjson; 10 | import generated.future.async.vertx.tables.records.SomethingRecord; 11 | import generated.future.async.vertx.tables.records.SomethingcompositeRecord; 12 | import generated.future.async.vertx.tables.records.SomethingwithoutjsonRecord; 13 | 14 | import javax.annotation.Generated; 15 | 16 | import org.jooq.Identity; 17 | import org.jooq.UniqueKey; 18 | import org.jooq.impl.AbstractKeys; 19 | 20 | 21 | /** 22 | * A class modelling foreign key relationships and constraints of tables of 23 | * the schema. 24 | */ 25 | @Generated( 26 | value = { 27 | "http://www.jooq.org", 28 | "jOOQ version:3.10.1" 29 | }, 30 | comments = "This class is generated by jOOQ" 31 | ) 32 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 33 | public class Keys { 34 | 35 | // ------------------------------------------------------------------------- 36 | // IDENTITY definitions 37 | // ------------------------------------------------------------------------- 38 | 39 | public static final Identity IDENTITY_SOMETHING = Identities0.IDENTITY_SOMETHING; 40 | public static final Identity IDENTITY_SOMETHINGWITHOUTJSON = Identities0.IDENTITY_SOMETHINGWITHOUTJSON; 41 | 42 | // ------------------------------------------------------------------------- 43 | // UNIQUE and PRIMARY KEY definitions 44 | // ------------------------------------------------------------------------- 45 | 46 | public static final UniqueKey KEY_SOMETHING_PRIMARY = UniqueKeys0.KEY_SOMETHING_PRIMARY; 47 | public static final UniqueKey KEY_SOMETHINGCOMPOSITE_PRIMARY = UniqueKeys0.KEY_SOMETHINGCOMPOSITE_PRIMARY; 48 | public static final UniqueKey KEY_SOMETHINGWITHOUTJSON_PRIMARY = UniqueKeys0.KEY_SOMETHINGWITHOUTJSON_PRIMARY; 49 | 50 | // ------------------------------------------------------------------------- 51 | // FOREIGN KEY definitions 52 | // ------------------------------------------------------------------------- 53 | 54 | 55 | // ------------------------------------------------------------------------- 56 | // [#1459] distribute members to avoid static initialisers > 64kb 57 | // ------------------------------------------------------------------------- 58 | 59 | private static class Identities0 extends AbstractKeys { 60 | public static Identity IDENTITY_SOMETHING = createIdentity(Something.SOMETHING, Something.SOMETHING.SOMEID); 61 | public static Identity IDENTITY_SOMETHINGWITHOUTJSON = createIdentity(Somethingwithoutjson.SOMETHINGWITHOUTJSON, Somethingwithoutjson.SOMETHINGWITHOUTJSON.SOMEID); 62 | } 63 | 64 | private static class UniqueKeys0 extends AbstractKeys { 65 | public static final UniqueKey KEY_SOMETHING_PRIMARY = createUniqueKey(Something.SOMETHING, "KEY_something_PRIMARY", Something.SOMETHING.SOMEID); 66 | public static final UniqueKey KEY_SOMETHINGCOMPOSITE_PRIMARY = createUniqueKey(Somethingcomposite.SOMETHINGCOMPOSITE, "KEY_somethingComposite_PRIMARY", Somethingcomposite.SOMETHINGCOMPOSITE.SOMEID, Somethingcomposite.SOMETHINGCOMPOSITE.SOMESECONDID); 67 | public static final UniqueKey KEY_SOMETHINGWITHOUTJSON_PRIMARY = createUniqueKey(Somethingwithoutjson.SOMETHINGWITHOUTJSON, "KEY_somethingWithoutJson_PRIMARY", Somethingwithoutjson.SOMETHINGWITHOUTJSON.SOMEID); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/classic/async/vertx/Keys.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.classic.async.vertx; 5 | 6 | 7 | import generated.classic.async.vertx.tables.Something; 8 | import generated.classic.async.vertx.tables.Somethingcomposite; 9 | import generated.classic.async.vertx.tables.Somethingwithoutjson; 10 | import generated.classic.async.vertx.tables.records.SomethingRecord; 11 | import generated.classic.async.vertx.tables.records.SomethingcompositeRecord; 12 | import generated.classic.async.vertx.tables.records.SomethingwithoutjsonRecord; 13 | 14 | import javax.annotation.Generated; 15 | 16 | import org.jooq.Identity; 17 | import org.jooq.UniqueKey; 18 | import org.jooq.impl.AbstractKeys; 19 | 20 | 21 | /** 22 | * A class modelling foreign key relationships and constraints of tables of 23 | * the schema. 24 | */ 25 | @Generated( 26 | value = { 27 | "http://www.jooq.org", 28 | "jOOQ version:3.10.1" 29 | }, 30 | comments = "This class is generated by jOOQ" 31 | ) 32 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 33 | public class Keys { 34 | 35 | // ------------------------------------------------------------------------- 36 | // IDENTITY definitions 37 | // ------------------------------------------------------------------------- 38 | 39 | public static final Identity IDENTITY_SOMETHING = Identities0.IDENTITY_SOMETHING; 40 | public static final Identity IDENTITY_SOMETHINGWITHOUTJSON = Identities0.IDENTITY_SOMETHINGWITHOUTJSON; 41 | 42 | // ------------------------------------------------------------------------- 43 | // UNIQUE and PRIMARY KEY definitions 44 | // ------------------------------------------------------------------------- 45 | 46 | public static final UniqueKey KEY_SOMETHING_PRIMARY = UniqueKeys0.KEY_SOMETHING_PRIMARY; 47 | public static final UniqueKey KEY_SOMETHINGCOMPOSITE_PRIMARY = UniqueKeys0.KEY_SOMETHINGCOMPOSITE_PRIMARY; 48 | public static final UniqueKey KEY_SOMETHINGWITHOUTJSON_PRIMARY = UniqueKeys0.KEY_SOMETHINGWITHOUTJSON_PRIMARY; 49 | 50 | // ------------------------------------------------------------------------- 51 | // FOREIGN KEY definitions 52 | // ------------------------------------------------------------------------- 53 | 54 | 55 | // ------------------------------------------------------------------------- 56 | // [#1459] distribute members to avoid static initialisers > 64kb 57 | // ------------------------------------------------------------------------- 58 | 59 | private static class Identities0 extends AbstractKeys { 60 | public static Identity IDENTITY_SOMETHING = createIdentity(Something.SOMETHING, Something.SOMETHING.SOMEID); 61 | public static Identity IDENTITY_SOMETHINGWITHOUTJSON = createIdentity(Somethingwithoutjson.SOMETHINGWITHOUTJSON, Somethingwithoutjson.SOMETHINGWITHOUTJSON.SOMEID); 62 | } 63 | 64 | private static class UniqueKeys0 extends AbstractKeys { 65 | public static final UniqueKey KEY_SOMETHING_PRIMARY = createUniqueKey(Something.SOMETHING, "KEY_something_PRIMARY", Something.SOMETHING.SOMEID); 66 | public static final UniqueKey KEY_SOMETHINGCOMPOSITE_PRIMARY = createUniqueKey(Somethingcomposite.SOMETHINGCOMPOSITE, "KEY_somethingComposite_PRIMARY", Somethingcomposite.SOMETHINGCOMPOSITE.SOMEID, Somethingcomposite.SOMETHINGCOMPOSITE.SOMESECONDID); 67 | public static final UniqueKey KEY_SOMETHINGWITHOUTJSON_PRIMARY = createUniqueKey(Somethingwithoutjson.SOMETHINGWITHOUTJSON, "KEY_somethingWithoutJson_PRIMARY", Somethingwithoutjson.SOMETHINGWITHOUTJSON.SOMEID); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/main/java/io/github/jklingsporn/vertx/jooq/async/generate/rx/RXAsyncVertxGuiceGenerator.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.generate.rx; 2 | 3 | import io.github.jklingsporn.vertx.jooq.async.generate.AbstractVertxGuiceGenerator; 4 | import org.jooq.util.JavaWriter; 5 | import org.jooq.util.TableDefinition; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * Created by jensklingsporn on 06.07.17. 11 | */ 12 | public class RXAsyncVertxGuiceGenerator extends AbstractVertxGuiceGenerator { 13 | 14 | public RXAsyncVertxGuiceGenerator() { 15 | super(RXAsyncVertxGenerator.VERTX_DAO_NAME); 16 | } 17 | 18 | public RXAsyncVertxGuiceGenerator(boolean generateJson, boolean generateGuiceModules, boolean generateInjectConfigurationMethod) { 19 | super(RXAsyncVertxGenerator.VERTX_DAO_NAME, generateJson, generateGuiceModules, generateInjectConfigurationMethod); 20 | } 21 | 22 | @Override 23 | protected void generateDAOImports(JavaWriter out) { 24 | out.println("import io.reactivex.Completable;"); 25 | out.println("import io.reactivex.Observable;"); 26 | out.println("import io.reactivex.Single;"); 27 | out.println("import io.github.jklingsporn.vertx.jooq.async.rx.util.RXTool;"); 28 | } 29 | 30 | @Override 31 | protected void generateFetchOneByMethods(JavaWriter out, String pType, String colName, String colClass, String colType, String colIdentifier) { 32 | out.tab(1).javadoc("Fetch a unique record that has %s = value asynchronously", colName); 33 | 34 | out.tab(1).println("public Single<%s> fetchOneBy%sAsync(%s value) {", pType,colClass, colType); 35 | out.tab(2).println("return RXTool.executeBlocking(h->h.complete(fetchOneBy%s(value)),vertx());", colClass); 36 | out.tab(1).println("}"); 37 | } 38 | 39 | @Override 40 | protected void generateFetchByMethods(JavaWriter out, String pType, String colName, String colClass, String colType, String colIdentifier) { 41 | out.tab(1).javadoc("Fetch records that have %s IN (values) asynchronously", colName); 42 | out.tab(1).println("public Single> fetchBy%sAsync(%s<%s> values) {", pType, colClass, List.class, 43 | colType); 44 | out.tab(2).println("return fetchAsync(%s,values);", colIdentifier); 45 | out.tab(1).println("}"); 46 | 47 | out.tab(1).javadoc("Fetch records that have %s IN (values) asynchronously", colName); 48 | out.tab(1).println("public Observable<%s> fetchBy%sObservable(%s<%s> values) {", pType, colClass, List.class, colType); 49 | out.tab(2).println("return fetchObservable(%s,values);", colIdentifier); 50 | out.tab(1).println("}"); 51 | } 52 | 53 | @Override 54 | protected void generateVertxGetterAndSetterConfigurationMethod(JavaWriter out) { 55 | out.println(); 56 | out.tab(1).println("private io.vertx.rxjava.core.Vertx vertx;"); 57 | out.println(); 58 | generateSetVertxAnnotation(out); 59 | out.tab(1).println("@Override"); 60 | out.tab(1).println("public void setVertx(io.vertx.core.Vertx vertx) {"); 61 | out.tab(2).println("this.vertx = new io.vertx.rxjava.core.Vertx(vertx);"); 62 | out.tab(1).println("}"); 63 | out.println(); 64 | out.tab(1).println("@Override"); 65 | out.tab(1).println("public void setVertx(io.vertx.rxjava.core.Vertx vertx) {"); 66 | out.tab(2).println("this.vertx = vertx;"); 67 | out.tab(1).println("}"); 68 | out.println(); 69 | out.tab(1).println("@Override"); 70 | out.tab(1).println("public io.vertx.rxjava.core.Vertx vertx() {"); 71 | out.tab(2).println("return this.vertx;"); 72 | out.tab(1).println("}"); 73 | out.println(); 74 | } 75 | 76 | @Override 77 | protected void renderInsertReturningOverwrite(TableDefinition table, JavaWriter out, String reason) { 78 | 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/main/java/io/github/jklingsporn/vertx/jooq/async/generate/classic/ClassicAsyncVertxGenerator.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.generate.classic; 2 | 3 | import io.github.jklingsporn.vertx.jooq.async.generate.AbstractVertxGenerator; 4 | import org.jooq.util.GeneratorStrategy; 5 | import org.jooq.util.JavaWriter; 6 | import org.jooq.util.TableDefinition; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * Created by jensklingsporn on 19.04.17. 12 | */ 13 | public class ClassicAsyncVertxGenerator extends AbstractVertxGenerator { 14 | 15 | public static final String VERTX_DAO_NAME = "io.github.jklingsporn.vertx.jooq.async.classic.VertxDAO"; 16 | 17 | @Override 18 | protected void generateDAOImports(JavaWriter out) { 19 | out.println("import io.vertx.core.Handler;"); 20 | out.println("import io.vertx.core.AsyncResult;"); 21 | out.println("import io.github.jklingsporn.vertx.jooq.async.classic.AsyncJooqSQLClient;"); 22 | } 23 | 24 | @Override 25 | protected void generateFetchOneByMethods(JavaWriter out, String pType, String colName, String colClass, String colType, String colIdentifier) { 26 | out.tab(1).javadoc("Fetch a unique record that has %s = value asynchronously", colName); 27 | 28 | out.tab(1).println("public void fetchOneBy%sAsync(%s value,Handler> resultHandler) {", colClass, colType,pType); 29 | out.tab(2).println("fetchOneAsync(%s,value,resultHandler);", colIdentifier); 30 | out.tab(1).println("}"); 31 | } 32 | 33 | @Override 34 | protected void generateFetchByMethods(JavaWriter out, String pType, String colName, String colClass, String colType, String colIdentifier) { 35 | out.tab(1).javadoc("Fetch records that have %s IN (values) asynchronously", colName); 36 | out.tab(1).println("public void fetchBy%sAsync(%s<%s> values,Handler>> resultHandler) {", colClass, List.class, colType,pType); 37 | //out.tab(2).println("return fetch(%s, values);", colIdentifier); 38 | out.tab(2).println("fetchAsync(%s,values,resultHandler);", colIdentifier); 39 | out.tab(1).println("}"); 40 | } 41 | 42 | @Override 43 | protected void generateVertxGetterAndSetterConfigurationMethod(JavaWriter out) { 44 | //nothing 45 | } 46 | 47 | @Override 48 | protected void generateDaoClassFooter(TableDefinition table, JavaWriter out) { 49 | super.generateDaoClassFooter(table, out); 50 | generateClientGetterAndSetter(out); 51 | generateJsonMapper(table,out); 52 | } 53 | 54 | protected void generateClientGetterAndSetter(JavaWriter out) { 55 | out.println(); 56 | out.tab(1).println("private AsyncJooqSQLClient client;"); 57 | out.println(); 58 | generateSetVertxAnnotation(out); 59 | out.tab(1).println("@Override"); 60 | out.tab(1).println("public void setClient(AsyncJooqSQLClient client) {"); 61 | out.tab(2).println("this.client = client;"); 62 | out.tab(1).println("}"); 63 | out.println(); 64 | out.tab(1).println("@Override"); 65 | out.tab(1).println("public AsyncJooqSQLClient client() {"); 66 | out.tab(2).println("return this.client;"); 67 | out.tab(1).println("}"); 68 | out.println(); 69 | } 70 | 71 | @Override 72 | protected void renderInsertReturningOverwrite(TableDefinition table, JavaWriter out, String reason) { 73 | out.println(); 74 | out.tab(1).println("@Override"); 75 | out.tab(1).println("public void insertReturningPrimaryAsync(%s object, Handler> resultHandler){", 76 | out.ref(getStrategy().getFullJavaClassName(table, GeneratorStrategy.Mode.POJO)), 77 | getKeyType(table.getPrimaryKey())); 78 | out.tab(2).println("throw new UnsupportedOperationException(\"%s\");",reason); 79 | out.tab(1).println("}"); 80 | out.println(); 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/rx/async/vertx/tables/pojos/Somethingwithoutjson.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.rx.async.vertx.tables.pojos; 5 | 6 | 7 | import generated.rx.async.vertx.tables.interfaces.ISomethingwithoutjson; 8 | 9 | import javax.annotation.Generated; 10 | 11 | 12 | /** 13 | * This class is generated by jOOQ. 14 | */ 15 | @Generated( 16 | value = { 17 | "http://www.jooq.org", 18 | "jOOQ version:3.10.1" 19 | }, 20 | comments = "This class is generated by jOOQ" 21 | ) 22 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 23 | public class Somethingwithoutjson implements ISomethingwithoutjson { 24 | 25 | private static final long serialVersionUID = -1485018254; 26 | 27 | private Integer someid; 28 | private String somestring; 29 | 30 | public Somethingwithoutjson() {} 31 | 32 | public Somethingwithoutjson(Somethingwithoutjson value) { 33 | this.someid = value.someid; 34 | this.somestring = value.somestring; 35 | } 36 | 37 | public Somethingwithoutjson( 38 | Integer someid, 39 | String somestring 40 | ) { 41 | this.someid = someid; 42 | this.somestring = somestring; 43 | } 44 | 45 | @Override 46 | public Integer getSomeid() { 47 | return this.someid; 48 | } 49 | 50 | @Override 51 | public Somethingwithoutjson setSomeid(Integer someid) { 52 | this.someid = someid; 53 | return this; 54 | } 55 | 56 | @Override 57 | public String getSomestring() { 58 | return this.somestring; 59 | } 60 | 61 | @Override 62 | public Somethingwithoutjson setSomestring(String somestring) { 63 | this.somestring = somestring; 64 | return this; 65 | } 66 | 67 | @Override 68 | public boolean equals(Object obj) { 69 | if (this == obj) 70 | return true; 71 | if (obj == null) 72 | return false; 73 | if (getClass() != obj.getClass()) 74 | return false; 75 | final Somethingwithoutjson other = (Somethingwithoutjson) obj; 76 | if (someid == null) { 77 | if (other.someid != null) 78 | return false; 79 | } 80 | else if (!someid.equals(other.someid)) 81 | return false; 82 | if (somestring == null) { 83 | if (other.somestring != null) 84 | return false; 85 | } 86 | else if (!somestring.equals(other.somestring)) 87 | return false; 88 | return true; 89 | } 90 | 91 | @Override 92 | public int hashCode() { 93 | final int prime = 31; 94 | int result = 1; 95 | result = prime * result + ((this.someid == null) ? 0 : this.someid.hashCode()); 96 | result = prime * result + ((this.somestring == null) ? 0 : this.somestring.hashCode()); 97 | return result; 98 | } 99 | 100 | @Override 101 | public String toString() { 102 | StringBuilder sb = new StringBuilder("Somethingwithoutjson ("); 103 | 104 | sb.append(someid); 105 | sb.append(", ").append(somestring); 106 | 107 | sb.append(")"); 108 | return sb.toString(); 109 | } 110 | 111 | // ------------------------------------------------------------------------- 112 | // FROM and INTO 113 | // ------------------------------------------------------------------------- 114 | 115 | /** 116 | * {@inheritDoc} 117 | */ 118 | @Override 119 | public void from(ISomethingwithoutjson from) { 120 | setSomeid(from.getSomeid()); 121 | setSomestring(from.getSomestring()); 122 | } 123 | 124 | /** 125 | * {@inheritDoc} 126 | */ 127 | @Override 128 | public E into(E into) { 129 | into.from(this); 130 | return into; 131 | } 132 | 133 | public Somethingwithoutjson(io.vertx.core.json.JsonObject json) { 134 | fromJson(json); 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/future/async/vertx/tables/pojos/Somethingwithoutjson.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.future.async.vertx.tables.pojos; 5 | 6 | 7 | import generated.future.async.vertx.tables.interfaces.ISomethingwithoutjson; 8 | 9 | import javax.annotation.Generated; 10 | 11 | 12 | /** 13 | * This class is generated by jOOQ. 14 | */ 15 | @Generated( 16 | value = { 17 | "http://www.jooq.org", 18 | "jOOQ version:3.10.1" 19 | }, 20 | comments = "This class is generated by jOOQ" 21 | ) 22 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 23 | public class Somethingwithoutjson implements ISomethingwithoutjson { 24 | 25 | private static final long serialVersionUID = 1426120300; 26 | 27 | private Integer someid; 28 | private String somestring; 29 | 30 | public Somethingwithoutjson() {} 31 | 32 | public Somethingwithoutjson(Somethingwithoutjson value) { 33 | this.someid = value.someid; 34 | this.somestring = value.somestring; 35 | } 36 | 37 | public Somethingwithoutjson( 38 | Integer someid, 39 | String somestring 40 | ) { 41 | this.someid = someid; 42 | this.somestring = somestring; 43 | } 44 | 45 | @Override 46 | public Integer getSomeid() { 47 | return this.someid; 48 | } 49 | 50 | @Override 51 | public Somethingwithoutjson setSomeid(Integer someid) { 52 | this.someid = someid; 53 | return this; 54 | } 55 | 56 | @Override 57 | public String getSomestring() { 58 | return this.somestring; 59 | } 60 | 61 | @Override 62 | public Somethingwithoutjson setSomestring(String somestring) { 63 | this.somestring = somestring; 64 | return this; 65 | } 66 | 67 | @Override 68 | public boolean equals(Object obj) { 69 | if (this == obj) 70 | return true; 71 | if (obj == null) 72 | return false; 73 | if (getClass() != obj.getClass()) 74 | return false; 75 | final Somethingwithoutjson other = (Somethingwithoutjson) obj; 76 | if (someid == null) { 77 | if (other.someid != null) 78 | return false; 79 | } 80 | else if (!someid.equals(other.someid)) 81 | return false; 82 | if (somestring == null) { 83 | if (other.somestring != null) 84 | return false; 85 | } 86 | else if (!somestring.equals(other.somestring)) 87 | return false; 88 | return true; 89 | } 90 | 91 | @Override 92 | public int hashCode() { 93 | final int prime = 31; 94 | int result = 1; 95 | result = prime * result + ((this.someid == null) ? 0 : this.someid.hashCode()); 96 | result = prime * result + ((this.somestring == null) ? 0 : this.somestring.hashCode()); 97 | return result; 98 | } 99 | 100 | @Override 101 | public String toString() { 102 | StringBuilder sb = new StringBuilder("Somethingwithoutjson ("); 103 | 104 | sb.append(someid); 105 | sb.append(", ").append(somestring); 106 | 107 | sb.append(")"); 108 | return sb.toString(); 109 | } 110 | 111 | // ------------------------------------------------------------------------- 112 | // FROM and INTO 113 | // ------------------------------------------------------------------------- 114 | 115 | /** 116 | * {@inheritDoc} 117 | */ 118 | @Override 119 | public void from(ISomethingwithoutjson from) { 120 | setSomeid(from.getSomeid()); 121 | setSomestring(from.getSomestring()); 122 | } 123 | 124 | /** 125 | * {@inheritDoc} 126 | */ 127 | @Override 128 | public E into(E into) { 129 | into.from(this); 130 | return into; 131 | } 132 | 133 | public Somethingwithoutjson(io.vertx.core.json.JsonObject json) { 134 | fromJson(json); 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/classic/async/vertx/tables/pojos/Somethingwithoutjson.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.classic.async.vertx.tables.pojos; 5 | 6 | 7 | import generated.classic.async.vertx.tables.interfaces.ISomethingwithoutjson; 8 | 9 | import javax.annotation.Generated; 10 | 11 | 12 | /** 13 | * This class is generated by jOOQ. 14 | */ 15 | @Generated( 16 | value = { 17 | "http://www.jooq.org", 18 | "jOOQ version:3.10.1" 19 | }, 20 | comments = "This class is generated by jOOQ" 21 | ) 22 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 23 | public class Somethingwithoutjson implements ISomethingwithoutjson { 24 | 25 | private static final long serialVersionUID = -398620438; 26 | 27 | private Integer someid; 28 | private String somestring; 29 | 30 | public Somethingwithoutjson() {} 31 | 32 | public Somethingwithoutjson(Somethingwithoutjson value) { 33 | this.someid = value.someid; 34 | this.somestring = value.somestring; 35 | } 36 | 37 | public Somethingwithoutjson( 38 | Integer someid, 39 | String somestring 40 | ) { 41 | this.someid = someid; 42 | this.somestring = somestring; 43 | } 44 | 45 | @Override 46 | public Integer getSomeid() { 47 | return this.someid; 48 | } 49 | 50 | @Override 51 | public Somethingwithoutjson setSomeid(Integer someid) { 52 | this.someid = someid; 53 | return this; 54 | } 55 | 56 | @Override 57 | public String getSomestring() { 58 | return this.somestring; 59 | } 60 | 61 | @Override 62 | public Somethingwithoutjson setSomestring(String somestring) { 63 | this.somestring = somestring; 64 | return this; 65 | } 66 | 67 | @Override 68 | public boolean equals(Object obj) { 69 | if (this == obj) 70 | return true; 71 | if (obj == null) 72 | return false; 73 | if (getClass() != obj.getClass()) 74 | return false; 75 | final Somethingwithoutjson other = (Somethingwithoutjson) obj; 76 | if (someid == null) { 77 | if (other.someid != null) 78 | return false; 79 | } 80 | else if (!someid.equals(other.someid)) 81 | return false; 82 | if (somestring == null) { 83 | if (other.somestring != null) 84 | return false; 85 | } 86 | else if (!somestring.equals(other.somestring)) 87 | return false; 88 | return true; 89 | } 90 | 91 | @Override 92 | public int hashCode() { 93 | final int prime = 31; 94 | int result = 1; 95 | result = prime * result + ((this.someid == null) ? 0 : this.someid.hashCode()); 96 | result = prime * result + ((this.somestring == null) ? 0 : this.somestring.hashCode()); 97 | return result; 98 | } 99 | 100 | @Override 101 | public String toString() { 102 | StringBuilder sb = new StringBuilder("Somethingwithoutjson ("); 103 | 104 | sb.append(someid); 105 | sb.append(", ").append(somestring); 106 | 107 | sb.append(")"); 108 | return sb.toString(); 109 | } 110 | 111 | // ------------------------------------------------------------------------- 112 | // FROM and INTO 113 | // ------------------------------------------------------------------------- 114 | 115 | /** 116 | * {@inheritDoc} 117 | */ 118 | @Override 119 | public void from(ISomethingwithoutjson from) { 120 | setSomeid(from.getSomeid()); 121 | setSomestring(from.getSomestring()); 122 | } 123 | 124 | /** 125 | * {@inheritDoc} 126 | */ 127 | @Override 128 | public E into(E into) { 129 | into.from(this); 130 | return into; 131 | } 132 | 133 | public Somethingwithoutjson(io.vertx.core.json.JsonObject json) { 134 | fromJson(json); 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/io/github/jklingsporn/vertx/jooq/async/generate/classic/VertxDaoTestBase.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.generate.classic; 2 | 3 | import generated.classic.async.vertx.tables.daos.SomethingDao; 4 | import generated.classic.async.vertx.tables.daos.SomethingcompositeDao; 5 | import generated.classic.async.vertx.tables.pojos.Something; 6 | import io.github.jklingsporn.vertx.jooq.async.classic.AsyncJooqSQLClient; 7 | import io.vertx.core.AsyncResult; 8 | import io.vertx.core.Handler; 9 | import io.vertx.core.Vertx; 10 | import io.vertx.core.json.JsonArray; 11 | import io.vertx.core.json.JsonObject; 12 | import io.vertx.core.logging.SLF4JLogDelegateFactory; 13 | import io.vertx.ext.asyncsql.MySQLClient; 14 | import org.jooq.Configuration; 15 | import org.jooq.SQLDialect; 16 | import org.jooq.impl.DefaultConfiguration; 17 | import org.junit.Assert; 18 | import org.junit.BeforeClass; 19 | 20 | import java.sql.SQLException; 21 | import java.util.Random; 22 | import java.util.concurrent.CountDownLatch; 23 | import java.util.concurrent.TimeUnit; 24 | import java.util.function.Consumer; 25 | 26 | /** 27 | * Created by jensklingsporn on 07.11.16. 28 | */ 29 | public class VertxDaoTestBase { 30 | 31 | protected static SomethingDao dao; 32 | protected static SomethingcompositeDao compositeDao; 33 | 34 | @BeforeClass 35 | public static void beforeClass() throws SQLException { 36 | // TestTool.setupDB(); 37 | System.setProperty("vertx.logger-delegate-factory-class-name", SLF4JLogDelegateFactory.class.getName()); 38 | Configuration configuration = new DefaultConfiguration(); 39 | configuration.set(SQLDialect.MYSQL); 40 | 41 | JsonObject config = new JsonObject().put("host", "127.0.0.1").put("username", "vertx").putNull("password").put("database","vertx"); 42 | dao = new SomethingDao(configuration); 43 | Vertx vertx = Vertx.vertx(); 44 | dao.setClient(AsyncJooqSQLClient.create(vertx, MySQLClient.createNonShared(vertx, config))); 45 | 46 | compositeDao = new SomethingcompositeDao(configuration); 47 | compositeDao.setClient(AsyncJooqSQLClient.create(vertx, MySQLClient.createNonShared(vertx, config))); 48 | } 49 | 50 | protected void await(CountDownLatch latch) throws InterruptedException { 51 | if(!latch.await(3, TimeUnit.SECONDS)){ 52 | Assert.fail("latch not triggered"); 53 | } 54 | } 55 | 56 | 57 | protected Handler> countdownLatchHandler(final CountDownLatch latch){ 58 | return h->{ 59 | if(h.failed()){ 60 | Assert.fail(h.cause().getMessage()); 61 | } 62 | latch.countDown(); 63 | }; 64 | } 65 | 66 | protected Handler> consumeOrFailHandler(Consumer consumer){ 67 | return h->{ 68 | if(h.succeeded()){ 69 | try{ 70 | consumer.accept(h.result()); 71 | }catch(Throwable e){ 72 | e.printStackTrace(); 73 | Assert.fail(e.getMessage()); 74 | } 75 | }else{ 76 | h.cause().printStackTrace(); 77 | Assert.fail(h.cause().getMessage()); 78 | } 79 | }; 80 | 81 | } 82 | 83 | static Something createSomethingWithId(){ 84 | Random random = new Random(); 85 | Something something = new Something(); 86 | something.setSomeid(random.nextInt()); 87 | something.setSomedouble(random.nextDouble()); 88 | something.setSomehugenumber(random.nextLong()); 89 | something.setSomejsonarray(new JsonArray().add(1).add(2).add(3)); 90 | something.setSomejsonobject(new JsonObject().put("key", "value")); 91 | something.setSomesmallnumber((short) random.nextInt(Short.MAX_VALUE)); 92 | something.setSomestring("my_string"); 93 | return something; 94 | } 95 | 96 | static Something createSomething(){ 97 | return createSomethingWithId().setSomeid(null); 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /vertx-jooq-async-rx/src/main/java/io/github/jklingsporn/vertx/jooq/async/rx/util/AsyncJooqSQLClientImpl.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.rx.util; 2 | 3 | import io.github.jklingsporn.vertx.jooq.async.rx.AsyncJooqSQLClient; 4 | import io.reactivex.Single; 5 | import io.vertx.core.json.JsonArray; 6 | import io.vertx.core.json.JsonObject; 7 | import io.vertx.ext.sql.UpdateResult; 8 | import io.vertx.reactivex.core.Vertx; 9 | import io.vertx.reactivex.ext.asyncsql.AsyncSQLClient; 10 | import io.vertx.reactivex.ext.sql.SQLConnection; 11 | import org.jooq.Param; 12 | import org.jooq.Query; 13 | 14 | import java.util.List; 15 | import java.util.Optional; 16 | import java.util.function.Function; 17 | import java.util.stream.Collectors; 18 | 19 | /** 20 | * Created by jensklingsporn on 13.06.17. 21 | */ 22 | public class AsyncJooqSQLClientImpl implements AsyncJooqSQLClient { 23 | 24 | private final Vertx vertx; 25 | private final AsyncSQLClient delegate; 26 | 27 | public AsyncJooqSQLClientImpl(Vertx vertx, AsyncSQLClient delegate) { 28 | this.vertx = vertx; 29 | this.delegate = delegate; 30 | } 31 | 32 | @Override 33 | public

Single> fetch(Query query, java.util.function.Function mapper){ 34 | return getConnection().flatMap(executeAndClose(sqlConnection -> 35 | sqlConnection.rxQueryWithParams(query.getSQL(), getBindValues(query)).map(rs -> 36 | rs.getRows().stream().map(mapper).collect(Collectors.toList()) 37 | ))); 38 | } 39 | 40 | @Override 41 | public

Single

fetchOne(Query query, Function mapper){ 42 | return getConnection().flatMap(executeAndClose(sqlConnection -> 43 | sqlConnection.rxQueryWithParams(query.getSQL(), getBindValues(query)).map(rs -> { 44 | Optional

optional = rs.getRows().stream().findFirst().map(mapper); 45 | return optional.orElseGet(() -> null); 46 | }))); 47 | } 48 | 49 | @Override 50 | public Single execute(Query query){ 51 | return getConnection() 52 | .flatMap(executeAndClose(sqlConnection -> 53 | sqlConnection 54 | .rxUpdateWithParams(query.getSQL(), getBindValues(query)) 55 | .map(UpdateResult::getUpdated)) 56 | ); 57 | } 58 | 59 | @Override 60 | public Single insertReturning(Query query) { 61 | return getConnection() 62 | .flatMap(executeAndClose(sqlConnection -> 63 | sqlConnection 64 | .rxUpdateWithParams(query.getSQL(), getBindValues(query)) 65 | .map(updateResult -> updateResult.getKeys().getLong(0))) 66 | ); 67 | } 68 | 69 | private JsonArray getBindValues(Query query) { 70 | JsonArray bindValues = new JsonArray(); 71 | for (Param param : query.getParams().values()) { 72 | Object value = convertToDatabaseType(param); 73 | if(value==null){ 74 | bindValues.addNull(); 75 | }else{ 76 | bindValues.add(value); 77 | } 78 | } 79 | return bindValues; 80 | } 81 | 82 | static Object convertToDatabaseType(Param param) { 83 | return param.getBinding().converter().to(param.getValue()); 84 | } 85 | 86 | /** 87 | * @return a CompletableFuture that returns a SQLConnection or an Exception. 88 | */ 89 | private Single getConnection(){ 90 | return delegate().rxGetConnection(); 91 | } 92 | 93 | private io.reactivex.functions.Function> executeAndClose(Function> func) { 94 | return sqlConnection -> func.apply(sqlConnection).doAfterTerminate(sqlConnection::close); 95 | } 96 | 97 | @Override 98 | public AsyncSQLClient delegate() { 99 | return delegate; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/io/github/jklingsporn/vertx/jooq/async/generate/future/VertxSomethingCompositeDaoTest.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.generate.future; 2 | 3 | import generated.future.async.vertx.tables.pojos.Somethingcomposite; 4 | import generated.future.async.vertx.tables.records.SomethingcompositeRecord; 5 | import io.vertx.core.json.JsonObject; 6 | import org.junit.Assert; 7 | import org.junit.Test; 8 | 9 | import java.util.concurrent.CountDownLatch; 10 | 11 | /** 12 | * Created by jensklingsporn on 02.11.16. 13 | */ 14 | public class VertxSomethingCompositeDaoTest extends VertxDaoTestBase { 15 | 16 | @Test 17 | public void asyncCRUDShouldSucceed() throws InterruptedException { 18 | CountDownLatch latch = new CountDownLatch(1); 19 | Somethingcomposite something = createSomething(0, 0); 20 | SomethingcompositeRecord somethingcompositeRecord = new SomethingcompositeRecord(); 21 | somethingcompositeRecord.from(something); 22 | compositeDao.insertExecAsync(something). 23 | thenCompose( 24 | v-> compositeDao.findByIdAsync(somethingcompositeRecord.key())). 25 | thenCompose(fetchSomething -> { 26 | fetchSomething.getSomejsonobject().put("foo", "bar"); 27 | return compositeDao.updateExecAsync(fetchSomething); 28 | }). 29 | thenCompose(v2->compositeDao.deleteExecAsync(somethingcompositeRecord.key())). 30 | whenComplete(failOrCountDown(latch)); 31 | await(latch); 32 | } 33 | 34 | 35 | @Test 36 | public void asyncCRUDExecShouldSucceed() throws InterruptedException { 37 | CountDownLatch latch = new CountDownLatch(1); 38 | Somethingcomposite something = createSomething(1, 1); 39 | SomethingcompositeRecord somethingcompositeRecord = new SomethingcompositeRecord(); 40 | somethingcompositeRecord.from(something); 41 | compositeDao.insertExecAsync(something). 42 | thenCompose( 43 | inserted-> { 44 | Assert.assertEquals(1L, inserted.longValue()); 45 | return compositeDao.findByIdAsync(somethingcompositeRecord.key()); 46 | }). 47 | thenCompose(fetchSomething -> { 48 | fetchSomething.getSomejsonobject().put("foo", "bar"); 49 | return compositeDao.updateExecAsync(fetchSomething); 50 | }). 51 | thenAccept(updated->Assert.assertEquals(1L,updated.longValue())). 52 | thenCompose(v -> compositeDao.deleteExecAsync(somethingcompositeRecord.key())). 53 | whenComplete(failOrCountDown(latch)); 54 | await(latch); 55 | } 56 | 57 | // @Test 58 | // public void testReturning(){ 59 | // CountDownLatch latch = new CountDownLatch(1); 60 | // dao.client().delegate().getConnection(sqlConnection->{ 61 | // if(sqlConnection.failed()){ 62 | // sqlConnection.cause().printStackTrace(); 63 | // } 64 | // sqlConnection.result().execute("insert into somethingComposite values(2,2,null)", ex -> { 65 | // if (ex.failed()) { 66 | // ex.cause().printStackTrace(); 67 | // } 68 | // sqlConnection.result().query("select LAST_INSERT_ID()", lastId -> { 69 | // if (lastId.failed()) { 70 | // lastId.cause().printStackTrace(); 71 | // } else { 72 | // Assert.assertEquals(1L, lastId.result().getResults().size()); 73 | // System.out.println(lastId.result().toJson()); 74 | // latch.countDown(); 75 | // } 76 | // }); 77 | // }); 78 | // }); 79 | // await(latch); 80 | // } 81 | 82 | 83 | private Somethingcomposite createSomething(int someId, int someSecondId){ 84 | Somethingcomposite something = new Somethingcomposite(); 85 | something.setSomeid(someId); 86 | something.setSomesecondid(someSecondId); 87 | something.setSomejsonobject(new JsonObject().put("key", "value")); 88 | return something; 89 | } 90 | 91 | 92 | } 93 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/io/github/jklingsporn/vertx/jooq/async/generate/rx/RXVertxDaoTestBase.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.generate.rx; 2 | 3 | import generated.rx.async.vertx.tables.daos.SomethingDao; 4 | import generated.rx.async.vertx.tables.daos.SomethingcompositeDao; 5 | import io.github.jklingsporn.vertx.jooq.async.generate.TestTool; 6 | import io.github.jklingsporn.vertx.jooq.async.rx.AsyncJooqSQLClient; 7 | import io.reactivex.CompletableObserver; 8 | import io.reactivex.Observer; 9 | import io.reactivex.SingleObserver; 10 | import io.reactivex.disposables.Disposable; 11 | import io.vertx.core.json.JsonObject; 12 | import io.vertx.reactivex.core.Vertx; 13 | import io.vertx.reactivex.ext.asyncsql.MySQLClient; 14 | import org.jooq.Configuration; 15 | import org.jooq.SQLDialect; 16 | import org.jooq.impl.DefaultConfiguration; 17 | import org.junit.Assert; 18 | import org.junit.BeforeClass; 19 | 20 | import java.sql.SQLException; 21 | import java.util.concurrent.CountDownLatch; 22 | import java.util.concurrent.TimeUnit; 23 | 24 | /** 25 | * @author Clement Escoffier 26 | * @author Jens Klingsporn 27 | */ 28 | public class RXVertxDaoTestBase { 29 | 30 | protected static SomethingDao dao; 31 | protected static SomethingcompositeDao compositeDao; 32 | 33 | @BeforeClass 34 | public static void beforeClass() throws SQLException { 35 | TestTool.setupDB(); 36 | Configuration configuration = new DefaultConfiguration(); 37 | configuration.set(SQLDialect.MYSQL); 38 | 39 | JsonObject config = new JsonObject().put("host", "127.0.0.1").put("username", "vertx").putNull("password").put("database","vertx"); 40 | dao = new SomethingDao(configuration); 41 | Vertx vertx = Vertx.vertx(); 42 | dao.setClient(AsyncJooqSQLClient.create(vertx, MySQLClient.createNonShared(vertx, config))); 43 | 44 | compositeDao = new SomethingcompositeDao(configuration); 45 | compositeDao.setClient(AsyncJooqSQLClient.create(vertx,MySQLClient.createNonShared(vertx, config))); 46 | } 47 | 48 | protected void await(CountDownLatch latch) throws InterruptedException { 49 | if(!latch.await(3, TimeUnit.SECONDS)){ 50 | Assert.fail("latch not triggered"); 51 | } 52 | } 53 | 54 | protected Observer failOrCountDownPlainObserver(CountDownLatch latch) { 55 | return new Observer() { 56 | @Override 57 | public void onSubscribe(Disposable d) { 58 | 59 | } 60 | 61 | @Override 62 | public void onNext(T t) { 63 | 64 | } 65 | 66 | @Override 67 | public void onError(Throwable e) { 68 | fail(e); 69 | } 70 | 71 | @Override 72 | public void onComplete() { 73 | latch.countDown(); 74 | } 75 | 76 | }; 77 | } 78 | 79 | protected SingleObserver failOrCountDownSingleObserver(CountDownLatch latch) { 80 | return new SingleObserver() { 81 | @Override 82 | public void onSubscribe(Disposable d) { 83 | 84 | } 85 | 86 | @Override 87 | public void onSuccess(T t) { 88 | latch.countDown(); 89 | } 90 | 91 | @Override 92 | public void onError(Throwable e) { 93 | fail(e); 94 | } 95 | 96 | }; 97 | } 98 | 99 | protected CompletableObserver failOrCountDownCompletableObserver(CountDownLatch latch) { 100 | return new CompletableObserver() { 101 | 102 | @Override 103 | public void onSubscribe(Disposable d) { 104 | 105 | } 106 | 107 | @Override 108 | public void onComplete() { 109 | latch.countDown(); 110 | } 111 | 112 | @Override 113 | public void onError(Throwable e) { 114 | fail(e); 115 | } 116 | 117 | }; 118 | } 119 | 120 | protected static void fail(Throwable t) { 121 | throw new RuntimeException(t); 122 | } 123 | 124 | } 125 | -------------------------------------------------------------------------------- /vertx-jooq-async-shared/src/main/java/io/github/jklingsporn/vertx/jooq/async/shared/internal/VertxDAOHelper.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.shared.internal; 2 | 3 | import io.github.jklingsporn.vertx.jooq.async.shared.VertxPojo; 4 | import io.vertx.core.impl.Arguments; 5 | import io.vertx.core.json.JsonObject; 6 | import org.jooq.*; 7 | import org.jooq.impl.DSL; 8 | 9 | import java.util.*; 10 | import java.util.function.BiFunction; 11 | import java.util.function.Function; 12 | 13 | import static org.jooq.impl.DSL.row; 14 | 15 | /** 16 | * Created by jensklingsporn on 23.11.17. 17 | * Utility class to reduce duplicate code in the different VertxDAO implementations. 18 | * Only meant to be used by vertx-jooq-async. 19 | */ 20 | public class VertxDAOHelper { 21 | 22 | private VertxDAOHelper() { 23 | } 24 | 25 | static EnumSet INSERT_RETURNING_SUPPORT = EnumSet.of(SQLDialect.MYSQL,SQLDialect.MYSQL_5_7,SQLDialect.MYSQL_8_0); 26 | 27 | 28 | @SuppressWarnings("unchecked") 29 | public static ,T,F> F applyConditionally(T id, Table table, Function function){ 30 | UniqueKey uk = table.getPrimaryKey(); 31 | Objects.requireNonNull(uk,()->"No primary key"); 32 | /** 33 | * Copied from jOOQs DAOImpl#equal-method 34 | */ 35 | TableField[] pk = uk.getFieldsArray(); 36 | Condition condition; 37 | if (pk.length == 1) { 38 | condition = ((Field) pk[0]).equal(pk[0].getDataType().convert(id)); 39 | } 40 | else { 41 | condition = row(pk).equal((Record) id); 42 | } 43 | return function.apply(condition); 44 | } 45 | 46 | 47 | @SuppressWarnings("unchecked") 48 | public static

,T,F> F updateExecAsync(P object, DAO dao, Function function){ 49 | DSLContext dslContext = DSL.using(dao.configuration()); 50 | UniqueKey pk = dao.getTable().getPrimaryKey(); 51 | R record = dslContext.newRecord(dao.getTable(), object); 52 | Condition where = DSL.trueCondition(); 53 | for (TableField tableField : pk.getFields()) { 54 | //exclude primary keys from update 55 | record.changed(tableField,false); 56 | where = where.and(((TableField)tableField).eq(record.get(tableField))); 57 | } 58 | Map valuesToUpdate = 59 | Arrays.stream(record.fields()) 60 | .collect(HashMap::new, (m, f) -> m.put(f.getName(), f.getValue(record)), HashMap::putAll); 61 | 62 | return function.apply(dslContext.update(dao.getTable()).set(valuesToUpdate).where(where)); 63 | } 64 | 65 | public static

,T,F> F insertExecAsync(P object, DAO dao,Function function){ 66 | return function.apply(DSL.using(dao.configuration()).insertInto(dao.getTable()).values(object.toJson().getMap().values())); 67 | } 68 | 69 | public static

,T,F> F countAsync(DAO dao,BiFunction>, F> function){ 70 | return function.apply(DSL.using(dao.configuration()).selectCount().from(dao.getTable()), json -> json.getMap().values().stream().findFirst()); 71 | } 72 | 73 | @SuppressWarnings("unchecked") 74 | public static

,T,F> F insertReturningPrimaryAsync(P object, DAO dao,BiFunction,F> function){ 75 | Arguments.require(INSERT_RETURNING_SUPPORT.contains(dao.configuration().dialect()), "Only MySQL supported"); 76 | UniqueKey key = dao.getTable().getPrimaryKey(); 77 | TableField tableField = key.getFieldsArray()[0]; 78 | Function keyConverter = lastId -> { 79 | T checkedResult; 80 | if(tableField.getType().equals(Integer.class)){ 81 | checkedResult = (T) Integer.valueOf(lastId.intValue()); 82 | }else{ 83 | checkedResult = (T) lastId; 84 | } 85 | return checkedResult; 86 | }; 87 | DSLContext dslContext = DSL.using(dao.configuration()); 88 | return function.apply(dslContext.insertInto(dao.getTable()).set(dslContext.newRecord(dao.getTable(), object)).returning(key.getFields()), keyConverter); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/future/async/vertx/tables/daos/SomethingwithoutjsonDao.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.future.async.vertx.tables.daos; 5 | 6 | 7 | import generated.future.async.vertx.tables.Somethingwithoutjson; 8 | import generated.future.async.vertx.tables.records.SomethingwithoutjsonRecord; 9 | 10 | import io.github.jklingsporn.vertx.jooq.async.future.VertxDAO; 11 | 12 | import java.util.List; 13 | 14 | import javax.annotation.Generated; 15 | 16 | import org.jooq.Configuration; 17 | import org.jooq.impl.DAOImpl; 18 | 19 | 20 | import java.util.concurrent.CompletableFuture; 21 | import io.github.jklingsporn.vertx.jooq.async.future.AsyncJooqSQLClient; 22 | /** 23 | * This class is generated by jOOQ. 24 | */ 25 | @Generated( 26 | value = { 27 | "http://www.jooq.org", 28 | "jOOQ version:3.10.1" 29 | }, 30 | comments = "This class is generated by jOOQ" 31 | ) 32 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 33 | public class SomethingwithoutjsonDao extends DAOImpl implements VertxDAO { 34 | 35 | /** 36 | * Create a new SomethingwithoutjsonDao without any configuration 37 | */ 38 | public SomethingwithoutjsonDao() { 39 | super(Somethingwithoutjson.SOMETHINGWITHOUTJSON, generated.future.async.vertx.tables.pojos.Somethingwithoutjson.class); 40 | } 41 | 42 | /** 43 | * Create a new SomethingwithoutjsonDao with an attached configuration 44 | */ 45 | public SomethingwithoutjsonDao(Configuration configuration) { 46 | super(Somethingwithoutjson.SOMETHINGWITHOUTJSON, generated.future.async.vertx.tables.pojos.Somethingwithoutjson.class, configuration); 47 | } 48 | 49 | /** 50 | * {@inheritDoc} 51 | */ 52 | @Override 53 | protected Integer getId(generated.future.async.vertx.tables.pojos.Somethingwithoutjson object) { 54 | return object.getSomeid(); 55 | } 56 | 57 | /** 58 | * Fetch records that have someId IN (values) 59 | */ 60 | public List fetchBySomeid(Integer... values) { 61 | return fetch(Somethingwithoutjson.SOMETHINGWITHOUTJSON.SOMEID, values); 62 | } 63 | 64 | /** 65 | * Fetch a unique record that has someId = value 66 | */ 67 | public generated.future.async.vertx.tables.pojos.Somethingwithoutjson fetchOneBySomeid(Integer value) { 68 | return fetchOne(Somethingwithoutjson.SOMETHINGWITHOUTJSON.SOMEID, value); 69 | } 70 | 71 | /** 72 | * Fetch records that have someString IN (values) 73 | */ 74 | public List fetchBySomestring(String... values) { 75 | return fetch(Somethingwithoutjson.SOMETHINGWITHOUTJSON.SOMESTRING, values); 76 | } 77 | 78 | /** 79 | * Fetch records that have someId IN (values) asynchronously 80 | */ 81 | public CompletableFuture> fetchBySomeidAsync(List values) { 82 | return fetchAsync(Somethingwithoutjson.SOMETHINGWITHOUTJSON.SOMEID,values); 83 | } 84 | 85 | /** 86 | * Fetch a unique record that has someId = value asynchronously 87 | */ 88 | public CompletableFuture fetchOneBySomeidAsync(Integer value) { 89 | return fetchOneAsync(Somethingwithoutjson.SOMETHINGWITHOUTJSON.SOMEID,value); 90 | } 91 | 92 | /** 93 | * Fetch records that have someString IN (values) asynchronously 94 | */ 95 | public CompletableFuture> fetchBySomestringAsync(List values) { 96 | return fetchAsync(Somethingwithoutjson.SOMETHINGWITHOUTJSON.SOMESTRING,values); 97 | } 98 | 99 | private AsyncJooqSQLClient client; 100 | 101 | @Override 102 | public void setClient(AsyncJooqSQLClient client) { 103 | this.client = client; 104 | } 105 | 106 | @Override 107 | public AsyncJooqSQLClient client() { 108 | return this.client; 109 | } 110 | 111 | @Override 112 | public java.util.function.Function jsonMapper() { 113 | return json -> 114 | new generated.future.async.vertx.tables.pojos.Somethingwithoutjson() 115 | .setSomeid(json.getInteger("someId")) 116 | .setSomestring(json.getString("someString")) 117 | ; 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/classic/async/vertx/tables/daos/SomethingwithoutjsonDao.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.classic.async.vertx.tables.daos; 5 | 6 | 7 | import generated.classic.async.vertx.tables.Somethingwithoutjson; 8 | import generated.classic.async.vertx.tables.records.SomethingwithoutjsonRecord; 9 | 10 | import io.github.jklingsporn.vertx.jooq.async.classic.VertxDAO; 11 | 12 | import java.util.List; 13 | 14 | import javax.annotation.Generated; 15 | 16 | import org.jooq.Configuration; 17 | import org.jooq.impl.DAOImpl; 18 | 19 | 20 | import io.vertx.core.Handler; 21 | import io.vertx.core.AsyncResult; 22 | import io.github.jklingsporn.vertx.jooq.async.classic.AsyncJooqSQLClient; 23 | /** 24 | * This class is generated by jOOQ. 25 | */ 26 | @Generated( 27 | value = { 28 | "http://www.jooq.org", 29 | "jOOQ version:3.10.1" 30 | }, 31 | comments = "This class is generated by jOOQ" 32 | ) 33 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 34 | public class SomethingwithoutjsonDao extends DAOImpl implements VertxDAO { 35 | 36 | /** 37 | * Create a new SomethingwithoutjsonDao without any configuration 38 | */ 39 | public SomethingwithoutjsonDao() { 40 | super(Somethingwithoutjson.SOMETHINGWITHOUTJSON, generated.classic.async.vertx.tables.pojos.Somethingwithoutjson.class); 41 | } 42 | 43 | /** 44 | * Create a new SomethingwithoutjsonDao with an attached configuration 45 | */ 46 | public SomethingwithoutjsonDao(Configuration configuration) { 47 | super(Somethingwithoutjson.SOMETHINGWITHOUTJSON, generated.classic.async.vertx.tables.pojos.Somethingwithoutjson.class, configuration); 48 | } 49 | 50 | /** 51 | * {@inheritDoc} 52 | */ 53 | @Override 54 | protected Integer getId(generated.classic.async.vertx.tables.pojos.Somethingwithoutjson object) { 55 | return object.getSomeid(); 56 | } 57 | 58 | /** 59 | * Fetch records that have someId IN (values) 60 | */ 61 | public List fetchBySomeid(Integer... values) { 62 | return fetch(Somethingwithoutjson.SOMETHINGWITHOUTJSON.SOMEID, values); 63 | } 64 | 65 | /** 66 | * Fetch a unique record that has someId = value 67 | */ 68 | public generated.classic.async.vertx.tables.pojos.Somethingwithoutjson fetchOneBySomeid(Integer value) { 69 | return fetchOne(Somethingwithoutjson.SOMETHINGWITHOUTJSON.SOMEID, value); 70 | } 71 | 72 | /** 73 | * Fetch records that have someString IN (values) 74 | */ 75 | public List fetchBySomestring(String... values) { 76 | return fetch(Somethingwithoutjson.SOMETHINGWITHOUTJSON.SOMESTRING, values); 77 | } 78 | 79 | /** 80 | * Fetch records that have someId IN (values) asynchronously 81 | */ 82 | public void fetchBySomeidAsync(List values,Handler>> resultHandler) { 83 | fetchAsync(Somethingwithoutjson.SOMETHINGWITHOUTJSON.SOMEID,values,resultHandler); 84 | } 85 | 86 | /** 87 | * Fetch a unique record that has someId = value asynchronously 88 | */ 89 | public void fetchOneBySomeidAsync(Integer value,Handler> resultHandler) { 90 | fetchOneAsync(Somethingwithoutjson.SOMETHINGWITHOUTJSON.SOMEID,value,resultHandler); 91 | } 92 | 93 | /** 94 | * Fetch records that have someString IN (values) asynchronously 95 | */ 96 | public void fetchBySomestringAsync(List values,Handler>> resultHandler) { 97 | fetchAsync(Somethingwithoutjson.SOMETHINGWITHOUTJSON.SOMESTRING,values,resultHandler); 98 | } 99 | 100 | private AsyncJooqSQLClient client; 101 | 102 | @Override 103 | public void setClient(AsyncJooqSQLClient client) { 104 | this.client = client; 105 | } 106 | 107 | @Override 108 | public AsyncJooqSQLClient client() { 109 | return this.client; 110 | } 111 | 112 | @Override 113 | public java.util.function.Function jsonMapper() { 114 | return json -> 115 | new generated.classic.async.vertx.tables.pojos.Somethingwithoutjson() 116 | .setSomeid(json.getInteger("someId")) 117 | .setSomestring(json.getString("someString")) 118 | ; 119 | } 120 | 121 | } 122 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/rx/async/vertx/tables/pojos/Somethingcomposite.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.rx.async.vertx.tables.pojos; 5 | 6 | 7 | import generated.rx.async.vertx.tables.interfaces.ISomethingcomposite; 8 | 9 | import io.vertx.core.json.JsonObject; 10 | 11 | import javax.annotation.Generated; 12 | 13 | 14 | /** 15 | * This class is generated by jOOQ. 16 | */ 17 | @Generated( 18 | value = { 19 | "http://www.jooq.org", 20 | "jOOQ version:3.10.1" 21 | }, 22 | comments = "This class is generated by jOOQ" 23 | ) 24 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 25 | public class Somethingcomposite implements ISomethingcomposite { 26 | 27 | private static final long serialVersionUID = 1336732096; 28 | 29 | private Integer someid; 30 | private Integer somesecondid; 31 | private JsonObject somejsonobject; 32 | 33 | public Somethingcomposite() {} 34 | 35 | public Somethingcomposite(Somethingcomposite value) { 36 | this.someid = value.someid; 37 | this.somesecondid = value.somesecondid; 38 | this.somejsonobject = value.somejsonobject; 39 | } 40 | 41 | public Somethingcomposite( 42 | Integer someid, 43 | Integer somesecondid, 44 | JsonObject somejsonobject 45 | ) { 46 | this.someid = someid; 47 | this.somesecondid = somesecondid; 48 | this.somejsonobject = somejsonobject; 49 | } 50 | 51 | @Override 52 | public Integer getSomeid() { 53 | return this.someid; 54 | } 55 | 56 | @Override 57 | public Somethingcomposite setSomeid(Integer someid) { 58 | this.someid = someid; 59 | return this; 60 | } 61 | 62 | @Override 63 | public Integer getSomesecondid() { 64 | return this.somesecondid; 65 | } 66 | 67 | @Override 68 | public Somethingcomposite setSomesecondid(Integer somesecondid) { 69 | this.somesecondid = somesecondid; 70 | return this; 71 | } 72 | 73 | @Override 74 | public JsonObject getSomejsonobject() { 75 | return this.somejsonobject; 76 | } 77 | 78 | @Override 79 | public Somethingcomposite setSomejsonobject(JsonObject somejsonobject) { 80 | this.somejsonobject = somejsonobject; 81 | return this; 82 | } 83 | 84 | @Override 85 | public boolean equals(Object obj) { 86 | if (this == obj) 87 | return true; 88 | if (obj == null) 89 | return false; 90 | if (getClass() != obj.getClass()) 91 | return false; 92 | final Somethingcomposite other = (Somethingcomposite) obj; 93 | if (someid == null) { 94 | if (other.someid != null) 95 | return false; 96 | } 97 | else if (!someid.equals(other.someid)) 98 | return false; 99 | if (somesecondid == null) { 100 | if (other.somesecondid != null) 101 | return false; 102 | } 103 | else if (!somesecondid.equals(other.somesecondid)) 104 | return false; 105 | if (somejsonobject == null) { 106 | if (other.somejsonobject != null) 107 | return false; 108 | } 109 | else if (!somejsonobject.equals(other.somejsonobject)) 110 | return false; 111 | return true; 112 | } 113 | 114 | @Override 115 | public int hashCode() { 116 | final int prime = 31; 117 | int result = 1; 118 | result = prime * result + ((this.someid == null) ? 0 : this.someid.hashCode()); 119 | result = prime * result + ((this.somesecondid == null) ? 0 : this.somesecondid.hashCode()); 120 | result = prime * result + ((this.somejsonobject == null) ? 0 : this.somejsonobject.hashCode()); 121 | return result; 122 | } 123 | 124 | @Override 125 | public String toString() { 126 | StringBuilder sb = new StringBuilder("Somethingcomposite ("); 127 | 128 | sb.append(someid); 129 | sb.append(", ").append(somesecondid); 130 | sb.append(", ").append(somejsonobject); 131 | 132 | sb.append(")"); 133 | return sb.toString(); 134 | } 135 | 136 | // ------------------------------------------------------------------------- 137 | // FROM and INTO 138 | // ------------------------------------------------------------------------- 139 | 140 | /** 141 | * {@inheritDoc} 142 | */ 143 | @Override 144 | public void from(ISomethingcomposite from) { 145 | setSomeid(from.getSomeid()); 146 | setSomesecondid(from.getSomesecondid()); 147 | setSomejsonobject(from.getSomejsonobject()); 148 | } 149 | 150 | /** 151 | * {@inheritDoc} 152 | */ 153 | @Override 154 | public E into(E into) { 155 | into.from(this); 156 | return into; 157 | } 158 | 159 | public Somethingcomposite(io.vertx.core.json.JsonObject json) { 160 | fromJson(json); 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/future/async/vertx/tables/pojos/Somethingcomposite.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.future.async.vertx.tables.pojos; 5 | 6 | 7 | import generated.future.async.vertx.tables.interfaces.ISomethingcomposite; 8 | 9 | import io.vertx.core.json.JsonObject; 10 | 11 | import javax.annotation.Generated; 12 | 13 | 14 | /** 15 | * This class is generated by jOOQ. 16 | */ 17 | @Generated( 18 | value = { 19 | "http://www.jooq.org", 20 | "jOOQ version:3.10.1" 21 | }, 22 | comments = "This class is generated by jOOQ" 23 | ) 24 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 25 | public class Somethingcomposite implements ISomethingcomposite { 26 | 27 | private static final long serialVersionUID = -100711418; 28 | 29 | private Integer someid; 30 | private Integer somesecondid; 31 | private JsonObject somejsonobject; 32 | 33 | public Somethingcomposite() {} 34 | 35 | public Somethingcomposite(Somethingcomposite value) { 36 | this.someid = value.someid; 37 | this.somesecondid = value.somesecondid; 38 | this.somejsonobject = value.somejsonobject; 39 | } 40 | 41 | public Somethingcomposite( 42 | Integer someid, 43 | Integer somesecondid, 44 | JsonObject somejsonobject 45 | ) { 46 | this.someid = someid; 47 | this.somesecondid = somesecondid; 48 | this.somejsonobject = somejsonobject; 49 | } 50 | 51 | @Override 52 | public Integer getSomeid() { 53 | return this.someid; 54 | } 55 | 56 | @Override 57 | public Somethingcomposite setSomeid(Integer someid) { 58 | this.someid = someid; 59 | return this; 60 | } 61 | 62 | @Override 63 | public Integer getSomesecondid() { 64 | return this.somesecondid; 65 | } 66 | 67 | @Override 68 | public Somethingcomposite setSomesecondid(Integer somesecondid) { 69 | this.somesecondid = somesecondid; 70 | return this; 71 | } 72 | 73 | @Override 74 | public JsonObject getSomejsonobject() { 75 | return this.somejsonobject; 76 | } 77 | 78 | @Override 79 | public Somethingcomposite setSomejsonobject(JsonObject somejsonobject) { 80 | this.somejsonobject = somejsonobject; 81 | return this; 82 | } 83 | 84 | @Override 85 | public boolean equals(Object obj) { 86 | if (this == obj) 87 | return true; 88 | if (obj == null) 89 | return false; 90 | if (getClass() != obj.getClass()) 91 | return false; 92 | final Somethingcomposite other = (Somethingcomposite) obj; 93 | if (someid == null) { 94 | if (other.someid != null) 95 | return false; 96 | } 97 | else if (!someid.equals(other.someid)) 98 | return false; 99 | if (somesecondid == null) { 100 | if (other.somesecondid != null) 101 | return false; 102 | } 103 | else if (!somesecondid.equals(other.somesecondid)) 104 | return false; 105 | if (somejsonobject == null) { 106 | if (other.somejsonobject != null) 107 | return false; 108 | } 109 | else if (!somejsonobject.equals(other.somejsonobject)) 110 | return false; 111 | return true; 112 | } 113 | 114 | @Override 115 | public int hashCode() { 116 | final int prime = 31; 117 | int result = 1; 118 | result = prime * result + ((this.someid == null) ? 0 : this.someid.hashCode()); 119 | result = prime * result + ((this.somesecondid == null) ? 0 : this.somesecondid.hashCode()); 120 | result = prime * result + ((this.somejsonobject == null) ? 0 : this.somejsonobject.hashCode()); 121 | return result; 122 | } 123 | 124 | @Override 125 | public String toString() { 126 | StringBuilder sb = new StringBuilder("Somethingcomposite ("); 127 | 128 | sb.append(someid); 129 | sb.append(", ").append(somesecondid); 130 | sb.append(", ").append(somejsonobject); 131 | 132 | sb.append(")"); 133 | return sb.toString(); 134 | } 135 | 136 | // ------------------------------------------------------------------------- 137 | // FROM and INTO 138 | // ------------------------------------------------------------------------- 139 | 140 | /** 141 | * {@inheritDoc} 142 | */ 143 | @Override 144 | public void from(ISomethingcomposite from) { 145 | setSomeid(from.getSomeid()); 146 | setSomesecondid(from.getSomesecondid()); 147 | setSomejsonobject(from.getSomejsonobject()); 148 | } 149 | 150 | /** 151 | * {@inheritDoc} 152 | */ 153 | @Override 154 | public E into(E into) { 155 | into.from(this); 156 | return into; 157 | } 158 | 159 | public Somethingcomposite(io.vertx.core.json.JsonObject json) { 160 | fromJson(json); 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/classic/async/vertx/tables/pojos/Somethingcomposite.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.classic.async.vertx.tables.pojos; 5 | 6 | 7 | import generated.classic.async.vertx.tables.interfaces.ISomethingcomposite; 8 | 9 | import io.vertx.core.json.JsonObject; 10 | 11 | import javax.annotation.Generated; 12 | 13 | 14 | /** 15 | * This class is generated by jOOQ. 16 | */ 17 | @Generated( 18 | value = { 19 | "http://www.jooq.org", 20 | "jOOQ version:3.10.1" 21 | }, 22 | comments = "This class is generated by jOOQ" 23 | ) 24 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 25 | public class Somethingcomposite implements ISomethingcomposite { 26 | 27 | private static final long serialVersionUID = -2005802168; 28 | 29 | private Integer someid; 30 | private Integer somesecondid; 31 | private JsonObject somejsonobject; 32 | 33 | public Somethingcomposite() {} 34 | 35 | public Somethingcomposite(Somethingcomposite value) { 36 | this.someid = value.someid; 37 | this.somesecondid = value.somesecondid; 38 | this.somejsonobject = value.somejsonobject; 39 | } 40 | 41 | public Somethingcomposite( 42 | Integer someid, 43 | Integer somesecondid, 44 | JsonObject somejsonobject 45 | ) { 46 | this.someid = someid; 47 | this.somesecondid = somesecondid; 48 | this.somejsonobject = somejsonobject; 49 | } 50 | 51 | @Override 52 | public Integer getSomeid() { 53 | return this.someid; 54 | } 55 | 56 | @Override 57 | public Somethingcomposite setSomeid(Integer someid) { 58 | this.someid = someid; 59 | return this; 60 | } 61 | 62 | @Override 63 | public Integer getSomesecondid() { 64 | return this.somesecondid; 65 | } 66 | 67 | @Override 68 | public Somethingcomposite setSomesecondid(Integer somesecondid) { 69 | this.somesecondid = somesecondid; 70 | return this; 71 | } 72 | 73 | @Override 74 | public JsonObject getSomejsonobject() { 75 | return this.somejsonobject; 76 | } 77 | 78 | @Override 79 | public Somethingcomposite setSomejsonobject(JsonObject somejsonobject) { 80 | this.somejsonobject = somejsonobject; 81 | return this; 82 | } 83 | 84 | @Override 85 | public boolean equals(Object obj) { 86 | if (this == obj) 87 | return true; 88 | if (obj == null) 89 | return false; 90 | if (getClass() != obj.getClass()) 91 | return false; 92 | final Somethingcomposite other = (Somethingcomposite) obj; 93 | if (someid == null) { 94 | if (other.someid != null) 95 | return false; 96 | } 97 | else if (!someid.equals(other.someid)) 98 | return false; 99 | if (somesecondid == null) { 100 | if (other.somesecondid != null) 101 | return false; 102 | } 103 | else if (!somesecondid.equals(other.somesecondid)) 104 | return false; 105 | if (somejsonobject == null) { 106 | if (other.somejsonobject != null) 107 | return false; 108 | } 109 | else if (!somejsonobject.equals(other.somejsonobject)) 110 | return false; 111 | return true; 112 | } 113 | 114 | @Override 115 | public int hashCode() { 116 | final int prime = 31; 117 | int result = 1; 118 | result = prime * result + ((this.someid == null) ? 0 : this.someid.hashCode()); 119 | result = prime * result + ((this.somesecondid == null) ? 0 : this.somesecondid.hashCode()); 120 | result = prime * result + ((this.somejsonobject == null) ? 0 : this.somejsonobject.hashCode()); 121 | return result; 122 | } 123 | 124 | @Override 125 | public String toString() { 126 | StringBuilder sb = new StringBuilder("Somethingcomposite ("); 127 | 128 | sb.append(someid); 129 | sb.append(", ").append(somesecondid); 130 | sb.append(", ").append(somejsonobject); 131 | 132 | sb.append(")"); 133 | return sb.toString(); 134 | } 135 | 136 | // ------------------------------------------------------------------------- 137 | // FROM and INTO 138 | // ------------------------------------------------------------------------- 139 | 140 | /** 141 | * {@inheritDoc} 142 | */ 143 | @Override 144 | public void from(ISomethingcomposite from) { 145 | setSomeid(from.getSomeid()); 146 | setSomesecondid(from.getSomesecondid()); 147 | setSomejsonobject(from.getSomejsonobject()); 148 | } 149 | 150 | /** 151 | * {@inheritDoc} 152 | */ 153 | @Override 154 | public E into(E into) { 155 | into.from(this); 156 | return into; 157 | } 158 | 159 | public Somethingcomposite(io.vertx.core.json.JsonObject json) { 160 | fromJson(json); 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/rx/async/vertx/tables/Somethingwithoutjson.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.rx.async.vertx.tables; 5 | 6 | 7 | import generated.rx.async.vertx.DefaultSchema; 8 | import generated.rx.async.vertx.Indexes; 9 | import generated.rx.async.vertx.Keys; 10 | import generated.rx.async.vertx.tables.records.SomethingwithoutjsonRecord; 11 | 12 | import java.util.Arrays; 13 | import java.util.List; 14 | 15 | import javax.annotation.Generated; 16 | 17 | import org.jooq.Field; 18 | import org.jooq.Identity; 19 | import org.jooq.Index; 20 | import org.jooq.Name; 21 | import org.jooq.Schema; 22 | import org.jooq.Table; 23 | import org.jooq.TableField; 24 | import org.jooq.UniqueKey; 25 | import org.jooq.impl.DSL; 26 | import org.jooq.impl.TableImpl; 27 | 28 | 29 | /** 30 | * This class is generated by jOOQ. 31 | */ 32 | @Generated( 33 | value = { 34 | "http://www.jooq.org", 35 | "jOOQ version:3.10.1" 36 | }, 37 | comments = "This class is generated by jOOQ" 38 | ) 39 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 40 | public class Somethingwithoutjson extends TableImpl { 41 | 42 | private static final long serialVersionUID = -1458355904; 43 | 44 | /** 45 | * The reference instance of somethingWithoutJson 46 | */ 47 | public static final Somethingwithoutjson SOMETHINGWITHOUTJSON = new Somethingwithoutjson(); 48 | 49 | /** 50 | * The class holding records for this type 51 | */ 52 | @Override 53 | public Class getRecordType() { 54 | return SomethingwithoutjsonRecord.class; 55 | } 56 | 57 | /** 58 | * The column somethingWithoutJson.someId. 59 | */ 60 | public final TableField SOMEID = createField("someId", org.jooq.impl.SQLDataType.INTEGER.nullable(false).identity(true), this, ""); 61 | 62 | /** 63 | * The column somethingWithoutJson.someString. 64 | */ 65 | public final TableField SOMESTRING = createField("someString", org.jooq.impl.SQLDataType.VARCHAR(45), this, ""); 66 | 67 | /** 68 | * Create a somethingWithoutJson table reference 69 | */ 70 | public Somethingwithoutjson() { 71 | this(DSL.name("somethingWithoutJson"), null); 72 | } 73 | 74 | /** 75 | * Create an aliased somethingWithoutJson table reference 76 | */ 77 | public Somethingwithoutjson(String alias) { 78 | this(DSL.name(alias), SOMETHINGWITHOUTJSON); 79 | } 80 | 81 | /** 82 | * Create an aliased somethingWithoutJson table reference 83 | */ 84 | public Somethingwithoutjson(Name alias) { 85 | this(alias, SOMETHINGWITHOUTJSON); 86 | } 87 | 88 | private Somethingwithoutjson(Name alias, Table aliased) { 89 | this(alias, aliased, null); 90 | } 91 | 92 | private Somethingwithoutjson(Name alias, Table aliased, Field[] parameters) { 93 | super(alias, null, aliased, parameters, ""); 94 | } 95 | 96 | /** 97 | * {@inheritDoc} 98 | */ 99 | @Override 100 | public Schema getSchema() { 101 | return DefaultSchema.DEFAULT_SCHEMA; 102 | } 103 | 104 | /** 105 | * {@inheritDoc} 106 | */ 107 | @Override 108 | public List getIndexes() { 109 | return Arrays.asList(Indexes.SOMETHINGWITHOUTJSON_PRIMARY); 110 | } 111 | 112 | /** 113 | * {@inheritDoc} 114 | */ 115 | @Override 116 | public Identity getIdentity() { 117 | return Keys.IDENTITY_SOMETHINGWITHOUTJSON; 118 | } 119 | 120 | /** 121 | * {@inheritDoc} 122 | */ 123 | @Override 124 | public UniqueKey getPrimaryKey() { 125 | return Keys.KEY_SOMETHINGWITHOUTJSON_PRIMARY; 126 | } 127 | 128 | /** 129 | * {@inheritDoc} 130 | */ 131 | @Override 132 | public List> getKeys() { 133 | return Arrays.>asList(Keys.KEY_SOMETHINGWITHOUTJSON_PRIMARY); 134 | } 135 | 136 | /** 137 | * {@inheritDoc} 138 | */ 139 | @Override 140 | public Somethingwithoutjson as(String alias) { 141 | return new Somethingwithoutjson(DSL.name(alias), this); 142 | } 143 | 144 | /** 145 | * {@inheritDoc} 146 | */ 147 | @Override 148 | public Somethingwithoutjson as(Name alias) { 149 | return new Somethingwithoutjson(alias, this); 150 | } 151 | 152 | /** 153 | * Rename this table 154 | */ 155 | @Override 156 | public Somethingwithoutjson rename(String name) { 157 | return new Somethingwithoutjson(DSL.name(name), null); 158 | } 159 | 160 | /** 161 | * Rename this table 162 | */ 163 | @Override 164 | public Somethingwithoutjson rename(Name name) { 165 | return new Somethingwithoutjson(name, null); 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/future/async/vertx/tables/Somethingwithoutjson.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.future.async.vertx.tables; 5 | 6 | 7 | import generated.future.async.vertx.DefaultSchema; 8 | import generated.future.async.vertx.Indexes; 9 | import generated.future.async.vertx.Keys; 10 | import generated.future.async.vertx.tables.records.SomethingwithoutjsonRecord; 11 | 12 | import java.util.Arrays; 13 | import java.util.List; 14 | 15 | import javax.annotation.Generated; 16 | 17 | import org.jooq.Field; 18 | import org.jooq.Identity; 19 | import org.jooq.Index; 20 | import org.jooq.Name; 21 | import org.jooq.Schema; 22 | import org.jooq.Table; 23 | import org.jooq.TableField; 24 | import org.jooq.UniqueKey; 25 | import org.jooq.impl.DSL; 26 | import org.jooq.impl.TableImpl; 27 | 28 | 29 | /** 30 | * This class is generated by jOOQ. 31 | */ 32 | @Generated( 33 | value = { 34 | "http://www.jooq.org", 35 | "jOOQ version:3.10.1" 36 | }, 37 | comments = "This class is generated by jOOQ" 38 | ) 39 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 40 | public class Somethingwithoutjson extends TableImpl { 41 | 42 | private static final long serialVersionUID = -1825499369; 43 | 44 | /** 45 | * The reference instance of somethingWithoutJson 46 | */ 47 | public static final Somethingwithoutjson SOMETHINGWITHOUTJSON = new Somethingwithoutjson(); 48 | 49 | /** 50 | * The class holding records for this type 51 | */ 52 | @Override 53 | public Class getRecordType() { 54 | return SomethingwithoutjsonRecord.class; 55 | } 56 | 57 | /** 58 | * The column somethingWithoutJson.someId. 59 | */ 60 | public final TableField SOMEID = createField("someId", org.jooq.impl.SQLDataType.INTEGER.nullable(false).identity(true), this, ""); 61 | 62 | /** 63 | * The column somethingWithoutJson.someString. 64 | */ 65 | public final TableField SOMESTRING = createField("someString", org.jooq.impl.SQLDataType.VARCHAR(45), this, ""); 66 | 67 | /** 68 | * Create a somethingWithoutJson table reference 69 | */ 70 | public Somethingwithoutjson() { 71 | this(DSL.name("somethingWithoutJson"), null); 72 | } 73 | 74 | /** 75 | * Create an aliased somethingWithoutJson table reference 76 | */ 77 | public Somethingwithoutjson(String alias) { 78 | this(DSL.name(alias), SOMETHINGWITHOUTJSON); 79 | } 80 | 81 | /** 82 | * Create an aliased somethingWithoutJson table reference 83 | */ 84 | public Somethingwithoutjson(Name alias) { 85 | this(alias, SOMETHINGWITHOUTJSON); 86 | } 87 | 88 | private Somethingwithoutjson(Name alias, Table aliased) { 89 | this(alias, aliased, null); 90 | } 91 | 92 | private Somethingwithoutjson(Name alias, Table aliased, Field[] parameters) { 93 | super(alias, null, aliased, parameters, ""); 94 | } 95 | 96 | /** 97 | * {@inheritDoc} 98 | */ 99 | @Override 100 | public Schema getSchema() { 101 | return DefaultSchema.DEFAULT_SCHEMA; 102 | } 103 | 104 | /** 105 | * {@inheritDoc} 106 | */ 107 | @Override 108 | public List getIndexes() { 109 | return Arrays.asList(Indexes.SOMETHINGWITHOUTJSON_PRIMARY); 110 | } 111 | 112 | /** 113 | * {@inheritDoc} 114 | */ 115 | @Override 116 | public Identity getIdentity() { 117 | return Keys.IDENTITY_SOMETHINGWITHOUTJSON; 118 | } 119 | 120 | /** 121 | * {@inheritDoc} 122 | */ 123 | @Override 124 | public UniqueKey getPrimaryKey() { 125 | return Keys.KEY_SOMETHINGWITHOUTJSON_PRIMARY; 126 | } 127 | 128 | /** 129 | * {@inheritDoc} 130 | */ 131 | @Override 132 | public List> getKeys() { 133 | return Arrays.>asList(Keys.KEY_SOMETHINGWITHOUTJSON_PRIMARY); 134 | } 135 | 136 | /** 137 | * {@inheritDoc} 138 | */ 139 | @Override 140 | public Somethingwithoutjson as(String alias) { 141 | return new Somethingwithoutjson(DSL.name(alias), this); 142 | } 143 | 144 | /** 145 | * {@inheritDoc} 146 | */ 147 | @Override 148 | public Somethingwithoutjson as(Name alias) { 149 | return new Somethingwithoutjson(alias, this); 150 | } 151 | 152 | /** 153 | * Rename this table 154 | */ 155 | @Override 156 | public Somethingwithoutjson rename(String name) { 157 | return new Somethingwithoutjson(DSL.name(name), null); 158 | } 159 | 160 | /** 161 | * Rename this table 162 | */ 163 | @Override 164 | public Somethingwithoutjson rename(Name name) { 165 | return new Somethingwithoutjson(name, null); 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/classic/async/vertx/tables/Somethingwithoutjson.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.classic.async.vertx.tables; 5 | 6 | 7 | import generated.classic.async.vertx.DefaultSchema; 8 | import generated.classic.async.vertx.Indexes; 9 | import generated.classic.async.vertx.Keys; 10 | import generated.classic.async.vertx.tables.records.SomethingwithoutjsonRecord; 11 | 12 | import java.util.Arrays; 13 | import java.util.List; 14 | 15 | import javax.annotation.Generated; 16 | 17 | import org.jooq.Field; 18 | import org.jooq.Identity; 19 | import org.jooq.Index; 20 | import org.jooq.Name; 21 | import org.jooq.Schema; 22 | import org.jooq.Table; 23 | import org.jooq.TableField; 24 | import org.jooq.UniqueKey; 25 | import org.jooq.impl.DSL; 26 | import org.jooq.impl.TableImpl; 27 | 28 | 29 | /** 30 | * This class is generated by jOOQ. 31 | */ 32 | @Generated( 33 | value = { 34 | "http://www.jooq.org", 35 | "jOOQ version:3.10.1" 36 | }, 37 | comments = "This class is generated by jOOQ" 38 | ) 39 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 40 | public class Somethingwithoutjson extends TableImpl { 41 | 42 | private static final long serialVersionUID = 1886899964; 43 | 44 | /** 45 | * The reference instance of somethingWithoutJson 46 | */ 47 | public static final Somethingwithoutjson SOMETHINGWITHOUTJSON = new Somethingwithoutjson(); 48 | 49 | /** 50 | * The class holding records for this type 51 | */ 52 | @Override 53 | public Class getRecordType() { 54 | return SomethingwithoutjsonRecord.class; 55 | } 56 | 57 | /** 58 | * The column somethingWithoutJson.someId. 59 | */ 60 | public final TableField SOMEID = createField("someId", org.jooq.impl.SQLDataType.INTEGER.nullable(false).identity(true), this, ""); 61 | 62 | /** 63 | * The column somethingWithoutJson.someString. 64 | */ 65 | public final TableField SOMESTRING = createField("someString", org.jooq.impl.SQLDataType.VARCHAR(45), this, ""); 66 | 67 | /** 68 | * Create a somethingWithoutJson table reference 69 | */ 70 | public Somethingwithoutjson() { 71 | this(DSL.name("somethingWithoutJson"), null); 72 | } 73 | 74 | /** 75 | * Create an aliased somethingWithoutJson table reference 76 | */ 77 | public Somethingwithoutjson(String alias) { 78 | this(DSL.name(alias), SOMETHINGWITHOUTJSON); 79 | } 80 | 81 | /** 82 | * Create an aliased somethingWithoutJson table reference 83 | */ 84 | public Somethingwithoutjson(Name alias) { 85 | this(alias, SOMETHINGWITHOUTJSON); 86 | } 87 | 88 | private Somethingwithoutjson(Name alias, Table aliased) { 89 | this(alias, aliased, null); 90 | } 91 | 92 | private Somethingwithoutjson(Name alias, Table aliased, Field[] parameters) { 93 | super(alias, null, aliased, parameters, ""); 94 | } 95 | 96 | /** 97 | * {@inheritDoc} 98 | */ 99 | @Override 100 | public Schema getSchema() { 101 | return DefaultSchema.DEFAULT_SCHEMA; 102 | } 103 | 104 | /** 105 | * {@inheritDoc} 106 | */ 107 | @Override 108 | public List getIndexes() { 109 | return Arrays.asList(Indexes.SOMETHINGWITHOUTJSON_PRIMARY); 110 | } 111 | 112 | /** 113 | * {@inheritDoc} 114 | */ 115 | @Override 116 | public Identity getIdentity() { 117 | return Keys.IDENTITY_SOMETHINGWITHOUTJSON; 118 | } 119 | 120 | /** 121 | * {@inheritDoc} 122 | */ 123 | @Override 124 | public UniqueKey getPrimaryKey() { 125 | return Keys.KEY_SOMETHINGWITHOUTJSON_PRIMARY; 126 | } 127 | 128 | /** 129 | * {@inheritDoc} 130 | */ 131 | @Override 132 | public List> getKeys() { 133 | return Arrays.>asList(Keys.KEY_SOMETHINGWITHOUTJSON_PRIMARY); 134 | } 135 | 136 | /** 137 | * {@inheritDoc} 138 | */ 139 | @Override 140 | public Somethingwithoutjson as(String alias) { 141 | return new Somethingwithoutjson(DSL.name(alias), this); 142 | } 143 | 144 | /** 145 | * {@inheritDoc} 146 | */ 147 | @Override 148 | public Somethingwithoutjson as(Name alias) { 149 | return new Somethingwithoutjson(alias, this); 150 | } 151 | 152 | /** 153 | * Rename this table 154 | */ 155 | @Override 156 | public Somethingwithoutjson rename(String name) { 157 | return new Somethingwithoutjson(DSL.name(name), null); 158 | } 159 | 160 | /** 161 | * Rename this table 162 | */ 163 | @Override 164 | public Somethingwithoutjson rename(Name name) { 165 | return new Somethingwithoutjson(name, null); 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/rx/async/vertx/tables/Somethingcomposite.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.rx.async.vertx.tables; 5 | 6 | 7 | import generated.rx.async.vertx.DefaultSchema; 8 | import generated.rx.async.vertx.Indexes; 9 | import generated.rx.async.vertx.Keys; 10 | import generated.rx.async.vertx.tables.records.SomethingcompositeRecord; 11 | 12 | import io.github.jklingsporn.vertx.jooq.async.shared.JsonObjectConverter; 13 | import io.vertx.core.json.JsonObject; 14 | 15 | import java.util.Arrays; 16 | import java.util.List; 17 | 18 | import javax.annotation.Generated; 19 | 20 | import org.jooq.Field; 21 | import org.jooq.Index; 22 | import org.jooq.Name; 23 | import org.jooq.Schema; 24 | import org.jooq.Table; 25 | import org.jooq.TableField; 26 | import org.jooq.UniqueKey; 27 | import org.jooq.impl.DSL; 28 | import org.jooq.impl.TableImpl; 29 | 30 | 31 | /** 32 | * This class is generated by jOOQ. 33 | */ 34 | @Generated( 35 | value = { 36 | "http://www.jooq.org", 37 | "jOOQ version:3.10.1" 38 | }, 39 | comments = "This class is generated by jOOQ" 40 | ) 41 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 42 | public class Somethingcomposite extends TableImpl { 43 | 44 | private static final long serialVersionUID = -539336773; 45 | 46 | /** 47 | * The reference instance of somethingComposite 48 | */ 49 | public static final Somethingcomposite SOMETHINGCOMPOSITE = new Somethingcomposite(); 50 | 51 | /** 52 | * The class holding records for this type 53 | */ 54 | @Override 55 | public Class getRecordType() { 56 | return SomethingcompositeRecord.class; 57 | } 58 | 59 | /** 60 | * The column somethingComposite.someId. 61 | */ 62 | public final TableField SOMEID = createField("someId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); 63 | 64 | /** 65 | * The column somethingComposite.someSecondId. 66 | */ 67 | public final TableField SOMESECONDID = createField("someSecondId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); 68 | 69 | /** 70 | * The column somethingComposite.someJsonObject. 71 | */ 72 | public final TableField SOMEJSONOBJECT = createField("someJsonObject", org.jooq.impl.SQLDataType.VARCHAR(45), this, "", new JsonObjectConverter()); 73 | 74 | /** 75 | * Create a somethingComposite table reference 76 | */ 77 | public Somethingcomposite() { 78 | this(DSL.name("somethingComposite"), null); 79 | } 80 | 81 | /** 82 | * Create an aliased somethingComposite table reference 83 | */ 84 | public Somethingcomposite(String alias) { 85 | this(DSL.name(alias), SOMETHINGCOMPOSITE); 86 | } 87 | 88 | /** 89 | * Create an aliased somethingComposite table reference 90 | */ 91 | public Somethingcomposite(Name alias) { 92 | this(alias, SOMETHINGCOMPOSITE); 93 | } 94 | 95 | private Somethingcomposite(Name alias, Table aliased) { 96 | this(alias, aliased, null); 97 | } 98 | 99 | private Somethingcomposite(Name alias, Table aliased, Field[] parameters) { 100 | super(alias, null, aliased, parameters, ""); 101 | } 102 | 103 | /** 104 | * {@inheritDoc} 105 | */ 106 | @Override 107 | public Schema getSchema() { 108 | return DefaultSchema.DEFAULT_SCHEMA; 109 | } 110 | 111 | /** 112 | * {@inheritDoc} 113 | */ 114 | @Override 115 | public List getIndexes() { 116 | return Arrays.asList(Indexes.SOMETHINGCOMPOSITE_PRIMARY); 117 | } 118 | 119 | /** 120 | * {@inheritDoc} 121 | */ 122 | @Override 123 | public UniqueKey getPrimaryKey() { 124 | return Keys.KEY_SOMETHINGCOMPOSITE_PRIMARY; 125 | } 126 | 127 | /** 128 | * {@inheritDoc} 129 | */ 130 | @Override 131 | public List> getKeys() { 132 | return Arrays.>asList(Keys.KEY_SOMETHINGCOMPOSITE_PRIMARY); 133 | } 134 | 135 | /** 136 | * {@inheritDoc} 137 | */ 138 | @Override 139 | public Somethingcomposite as(String alias) { 140 | return new Somethingcomposite(DSL.name(alias), this); 141 | } 142 | 143 | /** 144 | * {@inheritDoc} 145 | */ 146 | @Override 147 | public Somethingcomposite as(Name alias) { 148 | return new Somethingcomposite(alias, this); 149 | } 150 | 151 | /** 152 | * Rename this table 153 | */ 154 | @Override 155 | public Somethingcomposite rename(String name) { 156 | return new Somethingcomposite(DSL.name(name), null); 157 | } 158 | 159 | /** 160 | * Rename this table 161 | */ 162 | @Override 163 | public Somethingcomposite rename(Name name) { 164 | return new Somethingcomposite(name, null); 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/future/async/vertx/tables/Somethingcomposite.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.future.async.vertx.tables; 5 | 6 | 7 | import generated.future.async.vertx.DefaultSchema; 8 | import generated.future.async.vertx.Indexes; 9 | import generated.future.async.vertx.Keys; 10 | import generated.future.async.vertx.tables.records.SomethingcompositeRecord; 11 | 12 | import io.github.jklingsporn.vertx.jooq.async.shared.JsonObjectConverter; 13 | import io.vertx.core.json.JsonObject; 14 | 15 | import java.util.Arrays; 16 | import java.util.List; 17 | 18 | import javax.annotation.Generated; 19 | 20 | import org.jooq.Field; 21 | import org.jooq.Index; 22 | import org.jooq.Name; 23 | import org.jooq.Schema; 24 | import org.jooq.Table; 25 | import org.jooq.TableField; 26 | import org.jooq.UniqueKey; 27 | import org.jooq.impl.DSL; 28 | import org.jooq.impl.TableImpl; 29 | 30 | 31 | /** 32 | * This class is generated by jOOQ. 33 | */ 34 | @Generated( 35 | value = { 36 | "http://www.jooq.org", 37 | "jOOQ version:3.10.1" 38 | }, 39 | comments = "This class is generated by jOOQ" 40 | ) 41 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 42 | public class Somethingcomposite extends TableImpl { 43 | 44 | private static final long serialVersionUID = -1177557934; 45 | 46 | /** 47 | * The reference instance of somethingComposite 48 | */ 49 | public static final Somethingcomposite SOMETHINGCOMPOSITE = new Somethingcomposite(); 50 | 51 | /** 52 | * The class holding records for this type 53 | */ 54 | @Override 55 | public Class getRecordType() { 56 | return SomethingcompositeRecord.class; 57 | } 58 | 59 | /** 60 | * The column somethingComposite.someId. 61 | */ 62 | public final TableField SOMEID = createField("someId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); 63 | 64 | /** 65 | * The column somethingComposite.someSecondId. 66 | */ 67 | public final TableField SOMESECONDID = createField("someSecondId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); 68 | 69 | /** 70 | * The column somethingComposite.someJsonObject. 71 | */ 72 | public final TableField SOMEJSONOBJECT = createField("someJsonObject", org.jooq.impl.SQLDataType.VARCHAR(45), this, "", new JsonObjectConverter()); 73 | 74 | /** 75 | * Create a somethingComposite table reference 76 | */ 77 | public Somethingcomposite() { 78 | this(DSL.name("somethingComposite"), null); 79 | } 80 | 81 | /** 82 | * Create an aliased somethingComposite table reference 83 | */ 84 | public Somethingcomposite(String alias) { 85 | this(DSL.name(alias), SOMETHINGCOMPOSITE); 86 | } 87 | 88 | /** 89 | * Create an aliased somethingComposite table reference 90 | */ 91 | public Somethingcomposite(Name alias) { 92 | this(alias, SOMETHINGCOMPOSITE); 93 | } 94 | 95 | private Somethingcomposite(Name alias, Table aliased) { 96 | this(alias, aliased, null); 97 | } 98 | 99 | private Somethingcomposite(Name alias, Table aliased, Field[] parameters) { 100 | super(alias, null, aliased, parameters, ""); 101 | } 102 | 103 | /** 104 | * {@inheritDoc} 105 | */ 106 | @Override 107 | public Schema getSchema() { 108 | return DefaultSchema.DEFAULT_SCHEMA; 109 | } 110 | 111 | /** 112 | * {@inheritDoc} 113 | */ 114 | @Override 115 | public List getIndexes() { 116 | return Arrays.asList(Indexes.SOMETHINGCOMPOSITE_PRIMARY); 117 | } 118 | 119 | /** 120 | * {@inheritDoc} 121 | */ 122 | @Override 123 | public UniqueKey getPrimaryKey() { 124 | return Keys.KEY_SOMETHINGCOMPOSITE_PRIMARY; 125 | } 126 | 127 | /** 128 | * {@inheritDoc} 129 | */ 130 | @Override 131 | public List> getKeys() { 132 | return Arrays.>asList(Keys.KEY_SOMETHINGCOMPOSITE_PRIMARY); 133 | } 134 | 135 | /** 136 | * {@inheritDoc} 137 | */ 138 | @Override 139 | public Somethingcomposite as(String alias) { 140 | return new Somethingcomposite(DSL.name(alias), this); 141 | } 142 | 143 | /** 144 | * {@inheritDoc} 145 | */ 146 | @Override 147 | public Somethingcomposite as(Name alias) { 148 | return new Somethingcomposite(alias, this); 149 | } 150 | 151 | /** 152 | * Rename this table 153 | */ 154 | @Override 155 | public Somethingcomposite rename(String name) { 156 | return new Somethingcomposite(DSL.name(name), null); 157 | } 158 | 159 | /** 160 | * Rename this table 161 | */ 162 | @Override 163 | public Somethingcomposite rename(Name name) { 164 | return new Somethingcomposite(name, null); 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/classic/async/vertx/tables/Somethingcomposite.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.classic.async.vertx.tables; 5 | 6 | 7 | import generated.classic.async.vertx.DefaultSchema; 8 | import generated.classic.async.vertx.Indexes; 9 | import generated.classic.async.vertx.Keys; 10 | import generated.classic.async.vertx.tables.records.SomethingcompositeRecord; 11 | 12 | import io.github.jklingsporn.vertx.jooq.async.shared.JsonObjectConverter; 13 | import io.vertx.core.json.JsonObject; 14 | 15 | import java.util.Arrays; 16 | import java.util.List; 17 | 18 | import javax.annotation.Generated; 19 | 20 | import org.jooq.Field; 21 | import org.jooq.Index; 22 | import org.jooq.Name; 23 | import org.jooq.Schema; 24 | import org.jooq.Table; 25 | import org.jooq.TableField; 26 | import org.jooq.UniqueKey; 27 | import org.jooq.impl.DSL; 28 | import org.jooq.impl.TableImpl; 29 | 30 | 31 | /** 32 | * This class is generated by jOOQ. 33 | */ 34 | @Generated( 35 | value = { 36 | "http://www.jooq.org", 37 | "jOOQ version:3.10.1" 38 | }, 39 | comments = "This class is generated by jOOQ" 40 | ) 41 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 42 | public class Somethingcomposite extends TableImpl { 43 | 44 | private static final long serialVersionUID = -960569225; 45 | 46 | /** 47 | * The reference instance of somethingComposite 48 | */ 49 | public static final Somethingcomposite SOMETHINGCOMPOSITE = new Somethingcomposite(); 50 | 51 | /** 52 | * The class holding records for this type 53 | */ 54 | @Override 55 | public Class getRecordType() { 56 | return SomethingcompositeRecord.class; 57 | } 58 | 59 | /** 60 | * The column somethingComposite.someId. 61 | */ 62 | public final TableField SOMEID = createField("someId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); 63 | 64 | /** 65 | * The column somethingComposite.someSecondId. 66 | */ 67 | public final TableField SOMESECONDID = createField("someSecondId", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, ""); 68 | 69 | /** 70 | * The column somethingComposite.someJsonObject. 71 | */ 72 | public final TableField SOMEJSONOBJECT = createField("someJsonObject", org.jooq.impl.SQLDataType.VARCHAR(45), this, "", new JsonObjectConverter()); 73 | 74 | /** 75 | * Create a somethingComposite table reference 76 | */ 77 | public Somethingcomposite() { 78 | this(DSL.name("somethingComposite"), null); 79 | } 80 | 81 | /** 82 | * Create an aliased somethingComposite table reference 83 | */ 84 | public Somethingcomposite(String alias) { 85 | this(DSL.name(alias), SOMETHINGCOMPOSITE); 86 | } 87 | 88 | /** 89 | * Create an aliased somethingComposite table reference 90 | */ 91 | public Somethingcomposite(Name alias) { 92 | this(alias, SOMETHINGCOMPOSITE); 93 | } 94 | 95 | private Somethingcomposite(Name alias, Table aliased) { 96 | this(alias, aliased, null); 97 | } 98 | 99 | private Somethingcomposite(Name alias, Table aliased, Field[] parameters) { 100 | super(alias, null, aliased, parameters, ""); 101 | } 102 | 103 | /** 104 | * {@inheritDoc} 105 | */ 106 | @Override 107 | public Schema getSchema() { 108 | return DefaultSchema.DEFAULT_SCHEMA; 109 | } 110 | 111 | /** 112 | * {@inheritDoc} 113 | */ 114 | @Override 115 | public List getIndexes() { 116 | return Arrays.asList(Indexes.SOMETHINGCOMPOSITE_PRIMARY); 117 | } 118 | 119 | /** 120 | * {@inheritDoc} 121 | */ 122 | @Override 123 | public UniqueKey getPrimaryKey() { 124 | return Keys.KEY_SOMETHINGCOMPOSITE_PRIMARY; 125 | } 126 | 127 | /** 128 | * {@inheritDoc} 129 | */ 130 | @Override 131 | public List> getKeys() { 132 | return Arrays.>asList(Keys.KEY_SOMETHINGCOMPOSITE_PRIMARY); 133 | } 134 | 135 | /** 136 | * {@inheritDoc} 137 | */ 138 | @Override 139 | public Somethingcomposite as(String alias) { 140 | return new Somethingcomposite(DSL.name(alias), this); 141 | } 142 | 143 | /** 144 | * {@inheritDoc} 145 | */ 146 | @Override 147 | public Somethingcomposite as(Name alias) { 148 | return new Somethingcomposite(alias, this); 149 | } 150 | 151 | /** 152 | * Rename this table 153 | */ 154 | @Override 155 | public Somethingcomposite rename(String name) { 156 | return new Somethingcomposite(DSL.name(name), null); 157 | } 158 | 159 | /** 160 | * Rename this table 161 | */ 162 | @Override 163 | public Somethingcomposite rename(Name name) { 164 | return new Somethingcomposite(name, null); 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/future/async/vertx/tables/daos/SomethingcompositeDao.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.future.async.vertx.tables.daos; 5 | 6 | 7 | import generated.future.async.vertx.tables.Somethingcomposite; 8 | import generated.future.async.vertx.tables.records.SomethingcompositeRecord; 9 | 10 | import io.github.jklingsporn.vertx.jooq.async.future.VertxDAO; 11 | import io.vertx.core.json.JsonObject; 12 | 13 | import java.util.List; 14 | 15 | import javax.annotation.Generated; 16 | 17 | import org.jooq.Configuration; 18 | import org.jooq.Record2; 19 | import org.jooq.impl.DAOImpl; 20 | 21 | 22 | import java.util.concurrent.CompletableFuture; 23 | import io.github.jklingsporn.vertx.jooq.async.future.AsyncJooqSQLClient; 24 | /** 25 | * This class is generated by jOOQ. 26 | */ 27 | @Generated( 28 | value = { 29 | "http://www.jooq.org", 30 | "jOOQ version:3.10.1" 31 | }, 32 | comments = "This class is generated by jOOQ" 33 | ) 34 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 35 | public class SomethingcompositeDao extends DAOImpl> implements VertxDAO> { 36 | 37 | /** 38 | * Create a new SomethingcompositeDao without any configuration 39 | */ 40 | public SomethingcompositeDao() { 41 | super(Somethingcomposite.SOMETHINGCOMPOSITE, generated.future.async.vertx.tables.pojos.Somethingcomposite.class); 42 | } 43 | 44 | /** 45 | * Create a new SomethingcompositeDao with an attached configuration 46 | */ 47 | public SomethingcompositeDao(Configuration configuration) { 48 | super(Somethingcomposite.SOMETHINGCOMPOSITE, generated.future.async.vertx.tables.pojos.Somethingcomposite.class, configuration); 49 | } 50 | 51 | /** 52 | * {@inheritDoc} 53 | */ 54 | @Override 55 | protected Record2 getId(generated.future.async.vertx.tables.pojos.Somethingcomposite object) { 56 | return compositeKeyRecord(object.getSomeid(), object.getSomesecondid()); 57 | } 58 | 59 | /** 60 | * Fetch records that have someId IN (values) 61 | */ 62 | public List fetchBySomeid(Integer... values) { 63 | return fetch(Somethingcomposite.SOMETHINGCOMPOSITE.SOMEID, values); 64 | } 65 | 66 | /** 67 | * Fetch records that have someSecondId IN (values) 68 | */ 69 | public List fetchBySomesecondid(Integer... values) { 70 | return fetch(Somethingcomposite.SOMETHINGCOMPOSITE.SOMESECONDID, values); 71 | } 72 | 73 | /** 74 | * Fetch records that have someJsonObject IN (values) 75 | */ 76 | public List fetchBySomejsonobject(JsonObject... values) { 77 | return fetch(Somethingcomposite.SOMETHINGCOMPOSITE.SOMEJSONOBJECT, values); 78 | } 79 | 80 | /** 81 | * Fetch records that have someId IN (values) asynchronously 82 | */ 83 | public CompletableFuture> fetchBySomeidAsync(List values) { 84 | return fetchAsync(Somethingcomposite.SOMETHINGCOMPOSITE.SOMEID,values); 85 | } 86 | 87 | /** 88 | * Fetch records that have someSecondId IN (values) asynchronously 89 | */ 90 | public CompletableFuture> fetchBySomesecondidAsync(List values) { 91 | return fetchAsync(Somethingcomposite.SOMETHINGCOMPOSITE.SOMESECONDID,values); 92 | } 93 | 94 | /** 95 | * Fetch records that have someJsonObject IN (values) asynchronously 96 | */ 97 | public CompletableFuture> fetchBySomejsonobjectAsync(List values) { 98 | return fetchAsync(Somethingcomposite.SOMETHINGCOMPOSITE.SOMEJSONOBJECT,values); 99 | } 100 | 101 | private AsyncJooqSQLClient client; 102 | 103 | @Override 104 | public void setClient(AsyncJooqSQLClient client) { 105 | this.client = client; 106 | } 107 | 108 | @Override 109 | public AsyncJooqSQLClient client() { 110 | return this.client; 111 | } 112 | 113 | @Override 114 | public java.util.function.Function jsonMapper() { 115 | return json -> 116 | new generated.future.async.vertx.tables.pojos.Somethingcomposite() 117 | .setSomeid(json.getInteger("someId")) 118 | .setSomesecondid(json.getInteger("someSecondId")) 119 | .setSomejsonobject(io.github.jklingsporn.vertx.jooq.async.shared.JsonObjectConverter.getInstance().from(json.getString("someJsonObject"))) 120 | ; 121 | } 122 | 123 | } 124 | -------------------------------------------------------------------------------- /vertx-jooq-async-future/src/main/java/io/github/jklingsporn/vertx/jooq/async/future/impl/AsyncJooqSQLClientImpl.java: -------------------------------------------------------------------------------- 1 | package io.github.jklingsporn.vertx.jooq.async.future.impl; 2 | 3 | import io.github.jklingsporn.vertx.jooq.async.future.AsyncJooqSQLClient; 4 | import io.vertx.core.AsyncResult; 5 | import io.vertx.core.Handler; 6 | import io.vertx.core.Vertx; 7 | import io.vertx.core.json.JsonArray; 8 | import io.vertx.core.json.JsonObject; 9 | import io.vertx.ext.asyncsql.AsyncSQLClient; 10 | import io.vertx.ext.sql.SQLConnection; 11 | import io.vertx.ext.sql.UpdateResult; 12 | import me.escoffier.vertx.completablefuture.VertxCompletableFuture; 13 | import org.jooq.Param; 14 | import org.jooq.Query; 15 | import org.jooq.conf.ParamType; 16 | 17 | import java.util.List; 18 | import java.util.Optional; 19 | import java.util.concurrent.CompletableFuture; 20 | import java.util.function.Function; 21 | import java.util.stream.Collectors; 22 | 23 | /** 24 | * Created by jensklingsporn on 13.06.17. 25 | */ 26 | public class AsyncJooqSQLClientImpl implements AsyncJooqSQLClient { 27 | 28 | private final Vertx vertx; 29 | private final AsyncSQLClient delegate; 30 | 31 | public AsyncJooqSQLClientImpl(Vertx vertx, AsyncSQLClient delegate) { 32 | this.vertx = vertx; 33 | this.delegate = delegate; 34 | } 35 | 36 | @Override 37 | public

CompletableFuture> fetch(Query query, Function mapper){ 38 | return getConnection().thenCompose(sqlConnection -> { 39 | CompletableFuture> cf = new VertxCompletableFuture<>(vertx); 40 | sqlConnection.queryWithParams( 41 | query.getSQL(), 42 | getBindValues(query), 43 | executeAndClose(rs -> 44 | rs.getRows().stream().map(mapper).collect(Collectors.toList()), 45 | sqlConnection, 46 | cf) 47 | ); 48 | return cf; 49 | }); 50 | } 51 | 52 | @Override 53 | public

CompletableFuture

fetchOne(Query query, Function mapper){ 54 | return getConnection().thenCompose(sqlConnection -> { 55 | CompletableFuture

cf = new VertxCompletableFuture

(vertx); 56 | sqlConnection.queryWithParams(query.getSQL(), getBindValues(query), executeAndClose(rs -> { 57 | Optional

optional = rs.getRows().stream().findFirst().map(mapper); 58 | return optional.orElseGet(() -> null); 59 | }, sqlConnection, cf)); 60 | return cf; 61 | }); 62 | } 63 | 64 | @Override 65 | public CompletableFuture execute(Query query){ 66 | return getConnection().thenCompose(sqlConnection -> { 67 | CompletableFuture cf = new VertxCompletableFuture<>(vertx); 68 | JsonArray bindValues = getBindValues(query); 69 | sqlConnection.updateWithParams(query.getSQL(), bindValues, executeAndClose(UpdateResult::getUpdated,sqlConnection,cf)); 70 | return cf; 71 | }); 72 | } 73 | 74 | @Override 75 | public CompletableFuture insertReturning(Query query) { 76 | return getConnection().thenCompose(sqlConnection -> { 77 | CompletableFuture cf = new VertxCompletableFuture<>(vertx); 78 | sqlConnection.update(query.getSQL(ParamType.INLINED), executeAndClose(updateResult->updateResult.getKeys().getLong(0), sqlConnection, cf)); 79 | return cf; 80 | }); 81 | } 82 | 83 | private JsonArray getBindValues(Query query) { 84 | JsonArray bindValues = new JsonArray(); 85 | for (Param param : query.getParams().values()) { 86 | Object value = convertToDatabaseType(param); 87 | if(value==null){ 88 | bindValues.addNull(); 89 | }else{ 90 | bindValues.add(value); 91 | } 92 | } 93 | return bindValues; 94 | } 95 | 96 | static Object convertToDatabaseType(Param param) { 97 | return param.getBinding().converter().to(param.getValue()); 98 | } 99 | 100 | /** 101 | * @return a CompletableFuture that returns a SQLConnection or an Exception. 102 | */ 103 | private CompletableFuture getConnection(){ 104 | CompletableFuture cf = new VertxCompletableFuture<>(vertx); 105 | delegate.getConnection(h -> { 106 | if (h.succeeded()) { 107 | cf.complete(h.result()); 108 | } else { 109 | cf.completeExceptionally(h.cause()); 110 | } 111 | }); 112 | return cf; 113 | } 114 | 115 | private Handler> executeAndClose(Function func, SQLConnection sqlConnection, CompletableFuture

cf) { 116 | return rs -> { 117 | try{ 118 | if (rs.succeeded()) { 119 | cf.complete(func.apply(rs.result())); 120 | } else { 121 | cf.completeExceptionally(rs.cause()); 122 | } 123 | }finally { 124 | sqlConnection.close(); 125 | } 126 | }; 127 | } 128 | 129 | @Override 130 | public AsyncSQLClient delegate() { 131 | return delegate; 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /vertx-jooq-async-generate/src/test/java/generated/rx/async/vertx/tables/interfaces/ISomething.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is generated by jOOQ. 3 | */ 4 | package generated.rx.async.vertx.tables.interfaces; 5 | 6 | 7 | import io.github.jklingsporn.vertx.jooq.async.shared.VertxPojo; 8 | import io.vertx.core.json.JsonArray; 9 | import io.vertx.core.json.JsonObject; 10 | 11 | import java.io.Serializable; 12 | 13 | import javax.annotation.Generated; 14 | 15 | 16 | /** 17 | * This class is generated by jOOQ. 18 | */ 19 | @Generated( 20 | value = { 21 | "http://www.jooq.org", 22 | "jOOQ version:3.10.1" 23 | }, 24 | comments = "This class is generated by jOOQ" 25 | ) 26 | @SuppressWarnings({ "all", "unchecked", "rawtypes" }) 27 | public interface ISomething extends VertxPojo, Serializable { 28 | 29 | /** 30 | * Setter for something.someId. 31 | */ 32 | public ISomething setSomeid(Integer value); 33 | 34 | /** 35 | * Getter for something.someId. 36 | */ 37 | public Integer getSomeid(); 38 | 39 | /** 40 | * Setter for something.someString. 41 | */ 42 | public ISomething setSomestring(String value); 43 | 44 | /** 45 | * Getter for something.someString. 46 | */ 47 | public String getSomestring(); 48 | 49 | /** 50 | * Setter for something.someHugeNumber. 51 | */ 52 | public ISomething setSomehugenumber(Long value); 53 | 54 | /** 55 | * Getter for something.someHugeNumber. 56 | */ 57 | public Long getSomehugenumber(); 58 | 59 | /** 60 | * Setter for something.someSmallNumber. 61 | */ 62 | public ISomething setSomesmallnumber(Short value); 63 | 64 | /** 65 | * Getter for something.someSmallNumber. 66 | */ 67 | public Short getSomesmallnumber(); 68 | 69 | /** 70 | * Setter for something.someRegularNumber. 71 | */ 72 | public ISomething setSomeregularnumber(Integer value); 73 | 74 | /** 75 | * Getter for something.someRegularNumber. 76 | */ 77 | public Integer getSomeregularnumber(); 78 | 79 | /** 80 | * Setter for something.someDouble. 81 | */ 82 | public ISomething setSomedouble(Double value); 83 | 84 | /** 85 | * Getter for something.someDouble. 86 | */ 87 | public Double getSomedouble(); 88 | 89 | /** 90 | * Setter for something.someEnum. 91 | */ 92 | public ISomething setSomeenum(String value); 93 | 94 | /** 95 | * Getter for something.someEnum. 96 | */ 97 | public String getSomeenum(); 98 | 99 | /** 100 | * Setter for something.someJsonObject. 101 | */ 102 | public ISomething setSomejsonobject(JsonObject value); 103 | 104 | /** 105 | * Getter for something.someJsonObject. 106 | */ 107 | public JsonObject getSomejsonobject(); 108 | 109 | /** 110 | * Setter for something.someJsonArray. 111 | */ 112 | public ISomething setSomejsonarray(JsonArray value); 113 | 114 | /** 115 | * Getter for something.someJsonArray. 116 | */ 117 | public JsonArray getSomejsonarray(); 118 | 119 | // ------------------------------------------------------------------------- 120 | // FROM and INTO 121 | // ------------------------------------------------------------------------- 122 | 123 | /** 124 | * Load data from another generated Record/POJO implementing the common interface ISomething 125 | */ 126 | public void from(generated.rx.async.vertx.tables.interfaces.ISomething from); 127 | 128 | /** 129 | * Copy data into another generated Record/POJO implementing the common interface ISomething 130 | */ 131 | public E into(E into); 132 | 133 | @Override 134 | default ISomething fromJson(io.vertx.core.json.JsonObject json) { 135 | setSomeid(json.getInteger("someId")); 136 | setSomestring(json.getString("someString")); 137 | setSomehugenumber(json.getLong("someHugeNumber")); 138 | setSomesmallnumber(json.getInteger("someSmallNumber")==null?null:json.getInteger("someSmallNumber").shortValue()); 139 | setSomeregularnumber(json.getInteger("someRegularNumber")); 140 | setSomedouble(json.getDouble("someDouble")); 141 | setSomeenum(json.getString("someEnum")); 142 | setSomejsonobject(json.getJsonObject("someJsonObject")); 143 | setSomejsonarray(json.getJsonArray("someJsonArray")); 144 | return this; 145 | } 146 | 147 | 148 | @Override 149 | default io.vertx.core.json.JsonObject toJson() { 150 | io.vertx.core.json.JsonObject json = new io.vertx.core.json.JsonObject(); 151 | json.put("someId",getSomeid()); 152 | json.put("someString",getSomestring()); 153 | json.put("someHugeNumber",getSomehugenumber()); 154 | json.put("someSmallNumber",getSomesmallnumber()); 155 | json.put("someRegularNumber",getSomeregularnumber()); 156 | json.put("someDouble",getSomedouble()); 157 | json.put("someEnum",getSomeenum()); 158 | json.put("someJsonObject",getSomejsonobject()); 159 | json.put("someJsonArray",getSomejsonarray()); 160 | return json; 161 | } 162 | 163 | } 164 | --------------------------------------------------------------------------------