Meaningless Drivel is fun!
The moose likes Object Relational Mapping and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark ""hibernate_sequence" does not exist" Watch ""hibernate_sequence" does not exist" New topic

"hibernate_sequence" does not exist

ahmed yehia
Ranch Hand

Joined: Apr 22, 2006
Posts: 424

I got this exception trying execute (persist) the below code snippets:

Postgres tables are:
1- users (id, ...)
2- user_roles(user_id, role)
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Because you are using @GeneratedValue()

It will look for how the database that you are using generates ids. For MySql or HSQSL, there are increment fields that automatically increment. In Postgres or Oracle, they use sequence tables. Since you didn't specify a sequence table name, it will look for a sequence table named hibernate_sequence and use it for default. So you probably don't have such a sequence table in your database and now you get that error.

Either add a hibernate_sequence or
your own sequence table and use the annotations to name your sequence table that you have.

Hope that helps


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
ahmed yehia
Ranch Hand

Joined: Apr 22, 2006
Posts: 424
Thanks Mark, I also got it working using:
I agree. Here's the link:
subject: "hibernate_sequence" does not exist
It's not a secret anymore!