jOOQ BLOB support

148 views
Skip to first unread message

robert...@gmail.com

unread,
Jul 28, 2017, 7:09:22 PM7/28/17
to jOOQ User Group
Hi Lucas,

I'm looking to store user profiles in a DB (postgresql) and thinking to store a profile photo for each user in the User table. Unfortunately the Manual says jOOQ doesn't support BLOBs.

However, it also says they are mapped to byte[], which might work in my case (profile photos should be fairly small) if I'd be able to read and write them using a ByteArrayOutputStream/ByteArrayInputStream or similar.
How can I do that? Can I still use jOOQ's code generation?

Is there support for BLOBs planned in the near future?

Thank you,
Robert

Lukas Eder

unread,
Jul 30, 2017, 5:27:33 AM7/30/17
to jooq...@googlegroups.com
Hi Robert,

There are several reasons why jOOQ doesn't formally support LOBs in client API right now, as opposed to their semantically equivalent "base types" String (for CLOB) and byte[] (for BLOB). I'm listing this to give some context here:
  1. jOOQ aims for hiding all JDBC details from jOOQ client API. Specifically, Clob and Blob are quite "harsh" APIs with quite a few caveats that may even depend on JDBC driver specifics.
  2. Clob and Blob are resources with open connections to the database. This makes no sense in an ordinary jOOQ context, when eagerly fetching all the results through fetch() methods. fetchLazy() and fetchStream() might be candidates where Clob and Blob types could make sense as the underlying ResultSet and PreparedStatement are still open while consuming these resources.
  3. ByteArray{ Input | Output }Stream are two different types which cannot be represented as a single Field<T> type. If they would be chosen as <T> types, we'd get read-only or write-only fields. So for full lazy streaming support, we'd need another 2-way wrapper type, similar to Clob and Blob
  4. In many cases, streaming binary data isn't really necessary as the byte[] can be easily kept in memory (and it is done so for further processing anyway, e.g. when working with images), so the extra work might not really be needed. This is particularly true in Oracle, where BLOBs are the only binary types in the absences of a formal (VAR)BINARY type, and CLOBs start at 4000 bytes.
So, perhaps what jOOQ offers is sufficient for you already? I definitely think that manual section could be improved though.

Lukas

--
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 jooq-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages