Quote:
The database table is set for NO Auto Increment.. I did that because I want Hibernate to control the auto-incrementing and not the database. You know I don't want them to collide or have confusion.
If you are using a native generator type (either identity or sequence), there will be no confusion. Hibernate will rely on the database to generate the id for it. That said, increment will work fine, as you say, if you are not working in a cluster,
and no other application will be inserting data into the mapped table.
Quote:
As I mentioned, on page 53 of the Hibernate manual, chapter 3.. "Sequence" is specified for PostgreSql. "identity" is specified for DB2, MySql, SQL Server, and Hypersonice SQL.
Right, all I am saying is that when I set up a test schema (a Person to Address mapping, with Person.id generated by PostgreSQL), I had to use identity. sequence gave me errors. In particular, my table is defined as:
Code:
CREATE TABLE person
(
per_id serial NOT NULL,
per_first_name varchar(40) NOT NULL,
per_last_name varchar(40) NOT NULL,
per_weight_kg numeric(4,2),
per_height_m numeric(4,2),
per_birth_date date
)
and when I session.save(new Person(...)) with sequence, I get this:
Code:
ERROR [main] - ERROR: relation "hibernate_sequence" does not exist
org.hibernate.exception.SQLGrammarException: could not get next sequence value
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:59)
at ...
same with native. Identity, however, works fine. This very well may have to do with my schema and how I created my tables (I used pgAdmin III), or even possibly to do with the version: Win32 build of PostgreSQL 8.0).