Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a column in a PostgreSql database that is defined with type boolean[]. I wish to map this to a Java entity property using Hibernate 3.3.x. However, I cannot find a suitable Java type that Hibernate is happy to map to. I thought that the java.lang.Boolean[] would be the obvious choice, but Hibernate complains:

Caused by: org.hibernate.HibernateException:
    Wrong column type in schema.table for column mycolumn. Found: _bool, expected: bytea
    at org.hibernate.mapping.Table.validateColumns(Table.java:284)
    at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1130)

I have also tried the following property types without success:

  • java.lang.String
  • java.lang.boolean[]
  • java.lang.Byte[]

How can I map this column?

share|improve this question
1  
possible duplicate of mapping a postgres array with hibernate –  Pascal Thivent May 10 '10 at 18:07
    
I agree that this is a duplicate - thank you for finding it @Pascal. The link on the original is broken however and this question has since acquired a good answer from @Kartik so I am uncertain whether I should close it(?) –  teabot May 11 '10 at 7:50
    
Ideally, I'd say that Kartik should add his answer to the previous question and that this one should be closed. But I'm no one to decide this alone so, just let the community decide. –  Pascal Thivent May 11 '10 at 10:16

2 Answers 2

up vote 1 down vote accepted

You need to implement your own UserType. This article is very handy. I am including this link because the link in the original article is broken.

You can implement your customer user types by overriding some open source UserTypes

share|improve this answer
    
Thanks @Kartik - the links provided enabled me to implement a solution. –  teabot May 11 '10 at 10:12

This might help.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.