Statement returned no results for @GetGeneratedKeys exception encountered

10 views
Skip to first unread message

Michael Conrad

unread,
Dec 6, 2022, 12:55:54 PM12/6/22
to jd...@googlegroups.com, Jason Carter
Hello all,

I recent JDBI update is now causing us to receive a "Java.lang.IllegalStateException: SQL method returns primitive int, but statement returned no results" for the following code fragment?

How do I handle this use case with the most recent JDBI (insert does not succeed due to condition in where clause)?

@SqlUpdate("insert into " + table //
      + " (uid, item, subscription_id, subscription_uuid, details_json, start, expires)" //
      + " select :uid as uid, :item as item," //
      + " :subscription_id as subscription_id," //
      + " :subscription_uuid as subscription_uuid," //
      + " :details as details," //
      + " :start as start, :expires as expires" //
      + " from (select 1) as X where not exists" //
      + " (select uid from " //
      + table //
      + " where uid=:uid AND subscription_id=:subscription_id)")
@GetGeneratedKeys
int insert(@BindEntitlement Entitlement entitlement);


-Mike

Steven Schlansker

unread,
Jan 5, 2026, 12:00:03 PM (7 days ago) Jan 5
to jd...@googlegroups.com, Jason Carter
Hi Michael,

Going through my missed emails, wanted to see if you figured this out - maybe you're missing a "RETURNING" clause from your insert statement?

Best,
Steven
> --
> You received this message because you are subscribed to the Google Groups "jDBI" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to jdbi+uns...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/jdbi/2686ef90-aeb6-4de8-ba94-ac0f2a354e59%40newsrx.com.

Reply all
Reply to author
Forward
0 new messages