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

Is automapping to a concrete class gone? #15

Open
kdurnoga opened this issue Jan 16, 2018 · 5 comments
Open

Is automapping to a concrete class gone? #15

kdurnoga opened this issue Jan 16, 2018 · 5 comments

Comments

@kdurnoga
Copy link

I've just migrated from rxjava-jdbc to rxjava2-jdbc and noticed that automapping to a concrete class feature is missing. That was a really useful tiny little thing. Can we hope it returns at some point?

@davidmoten
Copy link
Owner

Yeah I did leave it out intentionally mainly because of type safety. If your constructor changes then you get no compile time indication and the complication of multiple constructors made the approach a bit unattractive to me. Probably your easiest workaround is to use an intermediate Tuple:

db.select("select name, score from person")
  .getAs(String.class, Integer.class)
  .map(x -> new Person(x._1, x._2));

@kdurnoga
Copy link
Author

I see, a pity. Working with tuples becomes cumbersome when the number of columns grows and you have to explicitly specify the type of each of them. Is it possible to reintroduce this functionality, possibly in some utility class?

@davidmoten
Copy link
Owner

So I'll mark it as an enhancement and pop it on my backlog. The code can be copied from rxjava-jdbc but I'd like to revisit some of the validation stuff (like the existence of multiple constructors with the same number of parameters for instance).

@kdurnoga
Copy link
Author

Much appreciated!

@cosmin-ionita
Copy link

@davidmoten I tried to fix this issue here: #53. Please let me know your thoughts!

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

No branches or pull requests

3 participants