I have a postgres database and im trying to fetch ...
# spring
x
I have a postgres database and im trying to fetch a jsonb[] column from it, but I can't seem to make this work
I imported
Copy code
@TypeDefs(
    TypeDef(name = "json", typeClass = JsonStringType::class),
    TypeDef(name = "jsonb", typeClass = JsonBinaryType::class)
)
it works fine for jsonbs of course, but doing
Copy code
@Type(type = "jsonb[]")
@Column(columnDefinition = "jsonb[]")
is of course not working
m
well I’m using this with spring and kotlin and it works quite well: https://github.com/vladmihalcea/hibernate-types
Copy code
for class annotation I have this: @TypeDef(name = "jsonb", typeClass = JsonBinaryType::class)
and for a list as an example:
Untitled
this is for postgresql
x
interesting! and that works well?
do you not do any parsing of it?
you're storing data like this in your db?: [{a:1}, {a:2}] and that parses it correctly? @Miguel Guilherme
m
yep
Untitled
I ommited the data but this is in my db like this
x
wow, that's really interesting, that's not at all how i expecetd it to behave
i'll give it a try, thank you
m
glad it was helpful 👍
b
really cool, I was going to need exactly that, thanks!
x
it didn’t work in my case sadly... i had to write custom generators
m
hmm, not sure what to say, it’s working perfectly for me, I’ve been using this library in all my projects java / kotlin with spring
Copy code
implementation("com.vladmihalcea:hibernate-types-52:2.10.2")
229 Views