0

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 like 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!

3
  • what provider are you using for your entity manager? can you post your saving code? Commented Mar 10, 2011 at 0:37
  • i do getEntityManager().persist(entity); // entity is my persisted bean with all the data and the int[] field, and the entity manager is a javax.persistence.EntityManager Commented Mar 10, 2011 at 19:15
  • in fact it seems that there are difficulties with either jpa or hibernate with postgres arrays see stackoverflow.com/questions/4332467/… Commented Mar 10, 2011 at 20:03

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.