Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sorinpepelea opened this issue Dec 11, 2018 · 0 comments
Open

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

sorinpepelea opened this issue Dec 11, 2018 · 0 comments

Comments

@sorinpepelea
Copy link

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 :
<T> TransactedSelectAutomappedBuilder<T> select(Class<T> cls);
in class : org.davidmoten.rx.jdbc.TxImpl
add method :
@Override
public <T> TransactedSelectAutomappedBuilder<T> select(Class<T> cls) {
return db.tx(this).select(cls);
}

in class : org.davidmoten.rx.jdbc.TransactedBuilder
add method :
public <T> TransactedSelectAutomappedBuilder<T> select(@Nonnull Class<T> 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant