Hello,
I can see that writing similar code all the time tends to get tedious, but
in this particular case, I don't think that throwing an exception upon an
"unexpected" value is a strong enough use-case to overload the execute API.
In order to keep our API regular, we'd have to touch quite a few methods
with this notion of "do something if a given int count is unexpected"
On the other hand, the fetch() API has functional overloads, such as
fetch(RecordMapper) and fetch(RecordHandler), which take the individual
Records as function arguments. Perhaps, there's room for an
execute(IntFunction) or execute(IntConsumer) - but personally, I don't see
much value in those either..., as you'd be replacing
if (query.execute() != ?) { throw ... }
by
query.execute(i -> if (i != ?) throw ... )
You can, of course, always either implement your own org.jooq.Query
subtype, or write utility methods...
Hope this helps,
Lukas
2015-03-31 14:07 GMT+02:00 Erpel <[email protected]>:
> Hi,
>
> I have a lot of code like
> if (query.execute() != ?) { throw ... }
>
> It would be nice to have Query.execute take a parameter with the expected
> results, and if it doesn't match throwing an exception. Kind of like
> fetchOne(). I could even think of execute doing a rollback if the expected
> result doesn't match, but that might be a step too far.
>
> --
> You received this message because you are subscribed to the Google Groups
> "jOOQ User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups "jOOQ
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.