Reputation: 711
I am following official psql user guide on composite types (https://www.postgresql.org/docs/current/rowtypes.html) and trying to implement SQLData for the inventory_item
type https://impossibl.github.io/pgjdbc-ng/docs/current/user-guide/#_java_sql_sqldata.
As far as I understand the type mapping of the SQLData implementation should be attached to the active connection. Which in my situation is not that easy (i am using clojure + clojure.java.jdbc + connection pooling). Also, it feels not right to add it to every connection.
Is there a way to set the mapping only once so every connection will use it?
The dummy implementation of the SQLData (readonly yet)
(deftype InventoryItem []
java.sql.SQLData
(getSQLTypeName [_]
"inventory_item")
(readSQL [_ stream _type]
{:name (.readString stream)
:supplier-id (.readInt stream)
:price (.readBigDecimal stream)})
(writeSQL [_ stream]))
Upvotes: 2
Views: 151