Spring Boot с JPA не может сохранить поле автоматического приращения в RedshiftJAVA

Программисты JAVA общаются здесь
Ответить Пред. темаСлед. тема
Anonymous
 Spring Boot с JPA не может сохранить поле автоматического приращения в Redshift

Сообщение Anonymous »

Попытался сохранить данные в таблице Redshift от Spring Boot. Получил ошибку из -за столбца идентификатора автоматического приращения. Ниже приведены код и ошибка.
класс объекта

Код: Выделить всё

@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;
}
class

Код: Выделить всё

StudentMarks studentMarks = new StudentMarks();
studentMarks.setName("test");
studentMarks.setSubject("science");
studentMarks.setMarks(78);
studentMarks.setCreatedDate(Instant.now);

studentMarksRepository.save(studentMarks);
при нажатии на API Получите эту ошибку

Код: Выделить всё

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
redshift db

Код: Выделить всё

    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
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «JAVA»