Details
- 
    Bug 
- 
    Status: Closed (View Workflow)
- 
    Major 
- 
    Resolution: Not a Bug
- 
    10.3.7
- 
    None
- 
    Linux Lubuntu 16.04 - Thinkpad X201i - RAM 8Gb - Spring Boot 2 2.0.3.RELEASE
Description
The sequence returns a negative number:
19:16:42.294 [main] DEBUG org.hibernate.event.internal.AbstractSaveEventListener - Generated identifier: -29, using strategy: org.hibernate.id.enhanced.SequenceStyleGenerator
The sequence definition:
| drop sequence if exists user_account_id_seq; | 
| create sequence user_account_id_seq; | 
| drop table if exists user_account; | 
| create table user_account ( | 
| -- id bigint(20) unsigned not null auto_increment, | 
| id bigint(20) unsigned not null default (next value for user_account_id_seq), | 
| version int(10) unsigned not null, | 
| firstname varchar(255) not null, | 
| lastname varchar(255) not null, | 
| password varchar(100), | 
| password_salt varchar(50), | 
| readable_password varchar(50), | 
| email varchar(50) not null, | 
| confirmed_email bit(1) not null check (confirmed_email in (0, 1)), | 
| work_phone varchar(20), | 
|   unique key email (email), | 
|   primary key (id) | 
| ); | 
| Â | 
| drop sequence if exists user_role_id_seq; | 
| create sequence user_role_id_seq; | 
| drop table if exists user_role; | 
| create table user_role ( | 
| -- id bigint(20) unsigned not null auto_increment, | 
| id bigint(20) unsigned not null default (next value for user_role_id_seq), | 
| version int(10) unsigned not null, | 
| user_account_id bigint(20) unsigned not null, | 
| role varchar(50) not null, | 
|   unique key user_role_u1 (user_account_id, role), | 
|   key user_account_id (user_account_id), | 
|   constraint user_role_fk1 foreign key (user_account_id) references user_account (id), | 
|   primary key (id) | 
| ); | 
| 
 | 
It is under the following Spring Hibernate configuration:
| @Id | 
| @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "id_generator") | 
| @Column(name = "id", updatable = false, nullable = false) | 
| private Long id; | 
| ... | 
| } | 
| Â | 
| @Entity | 
| @Table(name = "user_account") | 
| @SequenceGenerator(name = "id_generator", sequenceName = "user_account_id_seq") | 
| public class User extends AbstractEntity { | 
| ... | 
| }
 | 
The connection properties:
| spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MariaDB103Dialect | 
| spring.datasource.driver-class-name=net.sf.log4jdbc.DriverSpy | 
| spring.datasource.url=jdbc:log4jdbc:mysql://localhost:3306/useraccounttest?serverTimezone=UTC | 
| spring.datasource.username=useraccount | 
| spring.datasource.password=mypassword | 
| spring.jpa.show-sql=true |