automap function on SelectBuilder object does not work
adam-mahmood opened this issue · 6 comments
db.select( "SELECT RecIndex,Site FROM dbo.MEAS_CARRIER where Time >= ? ORDER BY RecIndex ASC") .parameterStream(Flowable.just(Instant.now().minus(Duration.ofHours(1).plus(Duration.ofMinutes(2))))
.delay(1, TimeUnit.SECONDS).repeat())
.autoMap(CarrierMeasuremnt.class).distinct();
Your automap function returns a Flowable, and when you subscribe to the Flowable the value is null!
Can you please help?
Thanks for the report, I'll have a look.
I think the problem is that the automapped object returns null
from the toString
method so you think you have a null object but you don't. Here's a runnable example using the Database.test()
method:
Database.test() //
.select("select score from person where name=?") //
.parameterStream(Flowable.just("FRED")) //
.autoMap(Score.class) //
.doOnNext(System.out::println) //
.doOnNext(x -> System.out.println(x.score())) //
.blockingSubscribe();
interface Score {
@Column
int score();
}
The output is:
null
21
The behaviour is definitely confusing so I'll make a change to generate a meaningful message from the automapped object's toString
method.
I've deployed 0.1-RC2 to Maven Central with the toString
method enhancement. Let me know if your issue is solved now.
Thank you David. I believe that has fixed the issue, however i will test at work tomorrow morning.
I must say you have done a brilliant job in creating this library.
Glad you like it @adam-mahmood. By the way use 0.1-RC3 to pick up another fix. Cheers.
Closing this because conversation is continuing in #3