开发者

Javax.persistence with @Entity bean saving int[] as bytea (postgres)

In my current project i have an @Entity bean, with, among others, an int[] field, which should match an integer[] field in my postgres database.

However, upon persisting my object i get an exception l开发者_开发百科ike this:

Internal Exception: org.postgresql.util.PSQLException: ERROR: column "drawset_basedata" is of type integer[] but expression is of type bytea
Error Code: 0
Call: INSERT INTO drawset (drawset_id, drawset_basedata, drawset_created, drawset_data) VALUES (?, ?, ?, ?)
    bind => [null, [B@19701da, null, [B@facd93]
Query: InsertObjectQuery(lotoFlow.Drawset[drawsetId=null])
    at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:333)

I used the debugger and i can see clearly that the baseData proprety is an initialised int[] variable, i don't understand why it arrives as an bytea.

Thanks!


Hibernate and JPA do not support PostgreSQL arrays, so your best bet is to normalize your model or run your SQL manually.

While it is true that PostgreSQL handles arrays very well, many other dbs do not. For this reason one generally does not expect great array support in cross-db frameworks.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜