-
Notifications
You must be signed in to change notification settings - Fork 53
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
insertReturningPrimary for Collection of pojos #120
Comments
What @Globegitter asks is a really useful feature. I was constrained to insert, make compose and then call select to obtains the primary key or some other value. JOOQ give you a possibility to get in return any value you want from an inserted record. Of course, I'm new to vertx-jooq library. Maybe there is some workaround with small effort to get this kind of feature. I'm using vertx with kotlin and I thought that using kotlin extension function I could do something. I'm aware of the intention of using QueryResult as generic and driver agnostic response is a very good thing. Reading source code I've found insertReturning method in ReactiveClassicQueryExecutor but honestly, I'm not sure how this can be used. Any suggestion welcome |
I agree this is a useful feature. Main issue here is, that this method's return-value needs to be parameterized on the DAO-Interface, as the return value depends on the API ( There is a workaround when working with the JDBC-driver. Write a helper-class like the following:
|
While thinking about integrating that feature, I realized it doesn't make sense to have it added like the existing |
@jklingsporn you make a good point. Returning list of IDs would be completely useless. |
So what do you suggest? Why not just using the insertReturningPrimary
methods on the dao?
Aleksandar <notifications@github.com> schrieb am Di., 28. Jan. 2020, 19:11:
… @jklingsporn <https://github.com/jklingsporn> you make a good point.
Returning list of IDs would be completely useless.
But, when you insert one row returning generated row ID is very useful and
in many cases, a developer is constrained to make another query to get it.
A simple use case would be insert parent-child row where a child needs
parent id as foreign key reference.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#120?email_source=notifications&email_token=ABQLZXRHLP7RLPAW2NIKNOTRABYOTA5CNFSM4IWFCJXKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKEKZPA#issuecomment-579382460>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABQLZXXQHM4FWGND7SHG2T3RABYOTANCNFSM4IWFCJXA>
.
|
To be honest I didn't see insertReturningPrimary methods on DAO. I did one simple project with this library and I need to deepen much more. As all our projects in the future will use this library for data access I must be sure about limitations. Thanks |
I've tried the method on generated DAOs. That is nice to have and solves a frequent use case. |
@jklingsporn that is a very good point you are making and I assumed that the order of the returned IDs would be matching the order of the inserted collection. But yes, returning a collection of pojos would also make sense. |
We have an insert for a collection of pojos so it would be nice if we could also get an
insertReturningPrimary
for a collection of pojos on theAbstractVertxDAO
or at least aninsertReturningMany
on thequeryExecutor
to be able to easily implement oneself.The text was updated successfully, but these errors were encountered: