Hibernate Schema Update Problems

For a while I’ve been having problems trying to get a SchemaUpdate working with Hibernate. Turns out the problem was me, not Hibernate. Newly created tables had a blank ACL, and I just needed to set them.

I’ve been using Hibernate for relational persistence for a while now, and I have to say it’s been working out pretty well.

That was, until I went to do a SchemaUpdate.

The moment I did an alternation of a table, or created a new entity, things went sour, and I was unable to read my old data. Was it me, or was it Hibernate?

could not initialize a collection
PSQLException: ERROR: permission denied for relation newtablejustadded

It was me.

Turns out Hibernate’s update was working just fine. There was no magic versioning or class hashing going on, detecting the change to the database.

The problem was the ACL was blank for the newly created entity table (I was using Postgres).

By issuing this command, all was fine again:

GRANT INSERT, SELECT, UPDATE, DELETE, REFERENCES ON newtable TO GROUP agroupIwasusing;

Since it took a while to figure out what was going on, I thought I’d post this to help others that follow a similar, yet frustrating, path.

0 thoughts on “Hibernate Schema Update Problems”

  1. I was doing some Hibernate stuff, ran into a “org.postgresql.util.PSQLException: ERROR permission denied for relation [tablename]” error and did a Google search to figure out what was going on.

    First hit, my own blog. Apparently I ran back into this obscure problem and solved it months ago. This is exactly the kind of reason I write this stuff down. 🙂 I just saved myself hours of work.

    The higher up exception, though I had to read downwards for the actual cause, were:
    org.hibernate.exception.SQLGrammarException: could not initialize a collection: [class/field#linenum]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.