davidmoten / davidmoten/rxjava2-jdbc

Enhancement of tx : tx.select(Class<?> cls)

Open
#37 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
394
Forks
41
Avg merge
2m
Merged PRs (30d)
1

Description

I propose this enhancement, in a transacted select , with possibility of using annotated interface...
like
` .flatMap(tx -> tx.select(Person.class)`
instead of
` .flatMap(tx -> tx.select("select * from person")`
I put it on test in the example bellow and also I am displaying what I've been altering to your code in order for this to work :
`Database.test()`
`.select(Person.class)`
` .parameter(2)`
` .transactedValuesOnly()`
` .get()`
` .flatMap(tx -> tx.update("update person set name=:name where id=:id")`
` .parameter("name", "blabla")`
` .parameter("id", tx.value().id())`
` .transactedValuesOnly()`
` .counts()`
` )`
` .flatMap(tx -> tx.select(Person.class)`
` .parameter(2)`
` .transactedValuesOnly()`
` .valuesOnly()`
` .get()`
` )`
` .subscribe(`
` v -> {out.println(v.name());},`
` e -> out.println(e.getMessage())`
` );`

Here are the modifications I've made to your last version of code (maven 0.2.0 version - thanks for quick publishing btw .. I appreciate it )

in class : org.davidmoten.rx.jdbc.TxWithoutValue
add method :
` TransactedSelectAutomappedBuilder select(Class cls);`
in class : org.davidmoten.rx.jdbc.TxImpl
add method :
` @Override`
` public TransactedSelectAutomappedBuilder select(Class cls) {`
` return db.tx(this).select(cls);`
` }`

in class : org.davidmoten.rx.jdbc.TransactedBuilder
add method :
`public TransactedSelectAutomappedBuilder select(@Nonnull Class cls) {`
` Preconditions.checkNotNull(cls, "cls cannot be null");`
` return new SelectAutomappedBuilder(cls, connections, db).transacted();`
` }`

I am not sure if is error free, I am not familiar with all the options this library has, but if you could look into it would be just great.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.