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

Automatic generation of result classes #841

Closed
electrum opened this issue Jun 28, 2017 · 5 comments
Closed

Automatic generation of result classes #841

electrum opened this issue Jun 28, 2017 · 5 comments
Labels
Milestone

Comments

@electrum
Copy link
Contributor

SQL Objects are really nice to use until you need to return a tuple. Then you have to create a custom class and mapper (or use BeanMapper and sacrifice immutability).

I'm envisioning something where you just write an interface and Jdbi generates the implementation. We'd want automatic mapping from result set names to getters, but allow overrides with annotations. Additionally, we need support for type conversion. For example, how to turn a varbinary into a UUID.

I started prototyping this many years ago (predates SQL Objects) but never got very far: https://github.com/electrum/dbmagic

Jackson has a similar idea: https://github.com/FasterXML/jackson-modules-base/tree/master/mrbean

@qualidafial qualidafial added this to the JDBI 3 Post-release (non-blocker) milestone Jun 28, 2017
@stevenschlansker
Copy link
Member

I love this idea.

@stevenschlansker
Copy link
Member

Oops, wrong button. I'm imagining that it fits in really nicely -- a type creates a RowMapper and each getter on that type recursively uses the RowMapper or ColumnMapper as appropriate for its type.

@brianm
Copy link
Member

brianm commented Nov 22, 2017

Immutables used to have a thing, and I have played with doing a solid one, but the code generation magic in there has been hairy enough that I have not made enough progress.

@stevenschlansker
Copy link
Member

I think we'll be solving this one via Immutables integration rather than writing another code generator. Check out #1282

@stevenschlansker
Copy link
Member

I'm calling this one fixed. Use Immutables, it's great :)

Let us know if there's any other piece missing here.

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

Successfully merging a pull request may close this issue.

4 participants