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
Allow use of immutable POJOs instead of requiring POJOs with setters #188
Comments
It's actually possible. Just implement RecordSetHandler interface and manually create immutable object from recordset. Then pass your RecordSetHandler implementation to e.g. executeAndFetch() method. In fact I prefer this way of using sql2o than automatic mapping. Less magic is better :-) |
I feel like hijacking the thread but SimpleFlatMapper as an integration point with sql2o and it supports Constructor injection. see |
I don't think sql2o requires setters. In this SO answer, it's written that it uses |
Has anyone successfully used sql2o with the Immutables library? Edit: Solved. I annotated the abstract class with |
Anyway I think it's useless to create a model without setters. On the contrary, it could be useful: you could use models also for doing queries. For example, my little code creator for sql2o, EWA, creates a method in the Repository that find rows from a table searching for the not null parameters of a passed model. And it has a similar method for deleting rows. Furthermore, you can pass a model with only some parameter set and update only the not null parameters. Limiting the model to a simple immutable data container is short-sighted. |
Would be awesome if sql2o supported this like DBUtils and other jdbc utility api's.
The text was updated successfully, but these errors were encountered: