Guice with DAOs

9 views
Skip to first unread message

skf...@gmail.com

unread,
Aug 31, 2019, 5:10:54 PM8/31/19
to jOOQ User Group
I'm using Vert.x Jooq in Kotlin. I'm wondering if there's a way to use Vert.x Guice to avoid passing the parameters jooqConfig and dbClient
UserDao(jooqConfig, dbClient)
and instead simplify it to

UserDao()

This is the text Vert.x handler:
private fun jooqRxAsyncHandler(context: RoutingContext) {
    val jooqConfig: Configuration = DefaultConfiguration().set(SQLDialect.POSTGRES)
    val dbCredentials = JsonObject()
        .put("host", "localhost")
        .put("username", "username")
        .put("password", "password")
        .put("database", "dbname")

    dbClient = PostgreSQLClient.createNonShared(vertx, com.datadeploytool.database.dbCredentials)

    val dao = UserDao(jooqConfig, dbClient)
    println("getting. client: $dbClient")

    dao.deleteByCondition(USER.EMAIL.eq("f...@g.com")).ignoreElement()
        .andThen(
            dao.insert(User("user...@g.com",
                "f...@g.com",
                Timestamp(System.currentTimeMillis()))
).ignoreElement() .andThen( dao.findOneByCondition(USER.EMAIL.eq("te...@test.com.zz")) ) .doOnEvent { something, x -> if (x == null) { context.response().putHeader("content-type", "text/html").end("JOOQ test $something") } else { System.err.println("Something failed badly: " + x.message) context.response().putHeader("content-type", "text/html").end("JOOQ error") } } .subscribe() println("done") }
Here is the generated DAO class:
/*
* This file is generated by jOOQ.
*/
package jooq.generated.tables.daos;


import io.github.jklingsporn.vertx.jooq.shared.async.AbstractAsyncVertxDAO;

import java.sql.Timestamp;
import java.util.List;

import javax.annotation.Generated;

import jooq.generated.tables.User;
import jooq.generated.tables.records.UserRecord;

import org.jooq.Configuration;


import io.reactivex.Single;
import java.util.Optional;
import io.github.jklingsporn.vertx.jooq.rx.async.AsyncRXQueryExecutor;
/**
* This class is generated by jOOQ.
*/
@Generated(
value = {
"http://www.jooq.org",
"jOOQ version:3.11.9"
},
comments = "This class is generated by jOOQ"
)
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
@javax.inject.Singleton
public class UserDao extends AbstractAsyncVertxDAO<UserRecord, jooq.generated.tables.pojos.User, String, Single<List<jooq.generated.tables.pojos.User>>, Single<Optional<jooq.generated.tables.pojos.User>>, Single<Integer>, Single<String>> implements io.github.jklingsporn.vertx.jooq.rx.VertxDAO<UserRecord,jooq.generated.tables.pojos.User,String> {
@javax.inject.Inject

/**
* @param configuration Used for rendering, so only SQLDialect must be set and must be one of the MYSQL types or POSTGRES.
* @param delegate A configured AsyncSQLClient that is used for query execution
*/
public UserDao(Configuration configuration,io.vertx.reactivex.ext.asyncsql.AsyncSQLClient delegate) {
super(User.USER, jooq.generated.tables.pojos.User.class, new AsyncRXQueryExecutor<UserRecord,jooq.generated.tables.pojos.User,String>(configuration,delegate,jooq.generated.tables.pojos.User::new, User.USER));
}

/**
* {@inheritDoc}
*/
@Override
protected String getId(jooq.generated.tables.pojos.User object) {
return object.getUserKey();
}

/**
* Find records that have <code>user_email IN (values)</code> asynchronously
*/
public Single<List<jooq.generated.tables.pojos.User>> findManyByUserEmail(List<String> values) {
return findManyByCondition(User.USER.USER_EMAIL.in(values));
}

/**
* Find records that have <code>user_change_date IN (values)</code> asynchronously
*/
public Single<List<jooq.generated.tables.pojos.User>> findManyByUserChangeDate(List<Timestamp> values) {
return findManyByCondition(User.USER.USER_CHANGE_DATE.in(values));
}

@Override
public AsyncRXQueryExecutor<UserRecord,jooq.generated.tables.pojos.User,String> queryExecutor(){
return (AsyncRXQueryExecutor<UserRecord,jooq.generated.tables.pojos.User,String>) super.queryExecutor();
}
}


Lukas Eder

unread,
Sep 2, 2019, 5:08:42 AM9/2/19
to jOOQ User Group
Thanks a lot for your question.

We're currently not offering support for this third party plugin. I suggest directing that feature request directly to the author of the plugin.

Thanks,
Lukas

--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/5ac409fa-a4a9-4cc5-9cba-db2fd20e8321%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages