Fork me on GitHub
#sql
<
2017-02-24
>
catilac18:02:34

👋:skin-tone-4: - I'd like to use java.jdbc with postgres jsonb. is there something specific i need to do in order to work with such types?

catilac18:02:44

I get this error when I try to insert:

user=> (j/insert-multi! db :schemas [ {:datab {:hello 123}} ])

PSQLException ERROR: column "datab" is of type jsonb but expression is of type hstore
  Hint: You will need to rewrite or cast the expression.
  Position: 40  org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse (QueryExecutorImpl.java:2412)

seancorfield18:02:10

PostgreSQL is kinda weird with so many custom data types 😐

seancorfield18:02:37

Or you could use raw SQL with a CAST() in it, via the j/execute! function

catilac18:02:11

ah cool! thanks for pointing me in the right direction. so i'll have to modify a few protocols and i should be set! definitely weird 🙂

seancorfield18:02:32

BTW, there’s a java.jdbc mailing list so once you have that working, you might consider joining that list and posting your solution there so it’s in the archives for the future!

catilac18:02:27

oh that would be great! thanks

seancorfield19:02:58

No, thank you (in advance!).

seancorfield19:02:38

That documentation is community-maintained so feel free to add issues and/or send PRs.