I have my entity class mapped like below:
@Entity
@Audited
@Table(name="messages_locale")
public class Locale {
@Id
@GeneratedValue
@Getter @Setter //Project Lombok's annotations, equal to generated getter and setter method
private int id;
(...)
I create clean new database ,and properties:
< prop key=”hibernate.hbm2ddl.auto” >create < /prop>
WHY THE HELL (Sorry, almost two days wasted on this bug) after created database, i got a sequence in my postgres db?:
CREATE SEQUENCE hibernate_sequence
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 2
CACHE 1;
ALTER TABLE hibernate_sequence
OWNER TO postgres;
I dont want to have a sequence, I want to have just auto increment auto generated values..
In PostgreSQL auto-increment is handled using the
SERIALpseudo type. You use this type when you executeCREATE TABLE.Now to the point – this
SERIALpseudo type creates a sequence.Autoincrement in
PostgreSQLis handled using the created sequence. The default value of theidcolumn becomes –nextval('your_sequence_name').In Hibernate for an
Userentity:Read here:
http://www.postgresql.org/docs/8.4/static/datatype-numeric.html#DATATYPE-SERIAL
http://www.neilconway.org/docs/sequences/