{"id":7029,"date":"2017-03-21T15:33:23","date_gmt":"2017-03-21T07:33:23","guid":{"rendered":"http:\/\/onthe8spot.com\/?p=7029"},"modified":"2017-03-21T15:33:23","modified_gmt":"2017-03-21T07:33:23","slug":"mybatis-postgresql-byte-array-and-bytea","status":"publish","type":"post","link":"http:\/\/onthe8spot.com\/index.php\/2017\/03\/21\/mybatis-postgresql-byte-array-and-bytea\/","title":{"rendered":"MyBatis, Postgresql, Byte Array and ByteA"},"content":{"rendered":"<p>&nbsp;<br \/>\nSpent about an hour or two trying to find the correct TypeHandler and jdbcType combination to be able to retrieve data from a bytea type column in a postgresql table.<br \/>\n&nbsp;<br \/>\nThis is what I got:<\/p>\n<pre> jdbcType=\"BINARY\" typeHandler=\"org.apache.ibatis.type.ByteArrayTypeHandler\"<\/pre>\n<p>Hope this helps someone.<br \/>\nFor inserting I used this combination:<\/p>\n<pre>javaType=byte[], jdbcType=BLOB, typeHandler=org.apache.ibatis.type.BlobTypeHandler<\/pre>\n<p>The error I encountered was :<br \/>\norg.postgresql.util.PSQLException: Bad value for type int : \\3<br \/>\n&nbsp;<br \/>\nThe error is caused by defaulting to the use of oid when the field was actually stored in the column and not elsewhere.<br \/>\n&nbsp;<br \/>\nComment if this was useful!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Spent about an hour or two trying to find the correct TypeHandler and jdbcType combination to be able to retrieve data from a bytea type column in a postgresql table. &nbsp; This is what I got: jdbcType=&#8221;BINARY&#8221; typeHandler=&#8221;org.apache.ibatis.type.ByteArrayTypeHandler&#8221; Hope this helps someone. For inserting I used this combination: javaType=byte[], jdbcType=BLOB, typeHandler=org.apache.ibatis.type.BlobTypeHandler The error I &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/onthe8spot.com\/index.php\/2017\/03\/21\/mybatis-postgresql-byte-array-and-bytea\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;MyBatis, Postgresql, Byte Array and ByteA&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[72],"tags":[],"class_list":["post-7029","post","type-post","status-publish","format-standard","hentry","category-programming"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/onthe8spot.com\/index.php\/wp-json\/wp\/v2\/posts\/7029","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/onthe8spot.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/onthe8spot.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/onthe8spot.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/onthe8spot.com\/index.php\/wp-json\/wp\/v2\/comments?post=7029"}],"version-history":[{"count":0,"href":"http:\/\/onthe8spot.com\/index.php\/wp-json\/wp\/v2\/posts\/7029\/revisions"}],"wp:attachment":[{"href":"http:\/\/onthe8spot.com\/index.php\/wp-json\/wp\/v2\/media?parent=7029"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/onthe8spot.com\/index.php\/wp-json\/wp\/v2\/categories?post=7029"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/onthe8spot.com\/index.php\/wp-json\/wp\/v2\/tags?post=7029"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}