The below code for Java works fine in Oracle-eclipselink-java, as we migrated the same to mariadb, we are facing the issue stated below.
Db sequence:
CREATE OR REPLACE SEQUENCE `com_seq` start with 370700 minvalue 1 maxvalue
9223372036854775806 increment by 1 cache 20 nocycle ENGINE=InnoDB
Java code/Entity class:
@Column(name = "ID")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "com_seq")
@SequenceGenerator(name = "com_test_sample ", sequenceName = "com_seq", allocationSize=1)
private Integer id;
Note: Strategy = sequence
or GenerationType.SEQUENCE
(tried with both).
When we try with above coding and it's defined values we are getting below error:
Field 'ID' doesn't have a default value
Error Code: 1364
Call: INSERT INTO com_test_sample (ACTION, COMPLAINT_ID, TEXT_PARAMS, CREATE_TIMESTAMP, DELETE_REMARK, OVV_STATUS, PREV_OVV_STATUS, REMARK, VALUE, PERSON_ID, SUB_PERSON_ID) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
bind => [DRAFT_STATUS_SET, 370703, null, 2022-10-11 19:37:38.22, null, DRAFT, null, null, null, 25071, 25071]
Query: InsertObjectQuery(de.wirthedv.OVV.complaintjournal.domain.ComplaintJournal@1f)