класс объекта
Код: Выделить всё
@Entity
@Data
@Table(name = "student_marks", schema = "staging")
public class StudentMarks{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
private String subject;
private Double mark;
private Instant createdDate;
}
Код: Выделить всё
StudentMarks studentMarks = new StudentMarks();
studentMarks.setName("test");
studentMarks.setSubject("science");
studentMarks.setMarks(78);
studentMarks.setCreatedDate(Instant.now);
studentMarksRepository.save(studentMarks);
Код: Выделить всё
Caused by: org.hibernate.HibernateException: The database returned no natively generated identity value\r\n\tat org.hibernate.id.IdentifierGeneratorHelper.getGeneratedIdentity(IdentifierGeneratorHelper.java:75)\r\n\tat org.hibernate.dialect.identity.GetGeneratedKeysDelegate.executeAndExtract(GetGeneratedKeysDelegate.java:62)\r\n\tat org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:43)\r\n\tat org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3279)\r\n\tat org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3914)\r\n\tat org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:84)\r\n\tat org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:645)\r\n\tat org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:282)\r\n\tat org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:263)\r\n\tat org.hibernate.engine.spi.ActionQueue.addAction
Код: Выделить всё
CREATE TABLE IF NOT EXISTS student_marks
(
id BIGINT NOT NULL DEFAULT "identity"(304420, 0, '1,1'::text)
,name VARCHAR(200)
,subject VARCHAR(20)
,mark BIGINT
,created_date DATE
,PRIMARY KEY (id)
)
Подробнее здесь: https://stackoverflow.com/questions/796 ... n-redshift