Я использую spring data jpa с базой данных postgres, у меня есть этот пример: package fr.enedis.pepsa.kepler.onescreen.domain;
@Entity
@Table(indexes = { @Index(name = "hashcode", columnList = "code") })
@FieldDefaults(level= AccessLevel.PRIVATE)
@Getter
@Setter
@ToString
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
public class Alert {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "alert_generator")
@SequenceGenerator(name="alert_generator", sequenceName = "alert_seq")
Long id;
String code;
@Enumerated(EnumType.STRING)
Environment environment;
@Enumerated(EnumType.STRING)
Application nna;
String alertName;
String host;
String cluster;
String agentInfo;
@Enumerated(EnumType.STRING)
Publisher publisher;
@Enumerated(EnumType.STRING)
Criticality criticality;
String alertInfo;
@Transient
long timestamp;
Timestamp startDate;
Timestamp endDate;
}
и сервис, который сохраняет этот объект :
public void savingTest(AlertVM a) {
Alert receivedAlert = new Alert(a);
receivedAlert.setCode(receivedAlert.generateCode());
//get DB alert if exist
Alert alert = alertRepository.findByCodeAndEndDateIsNull(receivedAlert.getCode()).orElse(receivedAlert);
switch (receivedAlert.getCriticality()) {
case CRITICAL: {
if(alert.getId() != null){
break;
}
alert.setStartDate(new Timestamp(alert.getTimestamp()*1000));
Alert as = alertRepository.save(alert);
System.out.println("--------------------------------------> " + as.toString());
break;
}
}
Когда я вызываю службу saveTest из контроллера отдыха, сохранение выполняется, но когда я прихожу от потребителя kafka, сохранение не выполняется и у меня есть этот выходной журнал в спящем режиме.
от потребителя kafka:
Hibernate: select alert0_.id as id1_0_, alert0_.agent_info as agent_in2_0_, alert0_.alert_info as alert_in3_0_, alert0_.alert_name as alert_na4_0_, alert0_.cluster as cluster5_0_, alert0_.code as code6_0_, alert0_.criticality as critical7_0_, alert0_.end_date as end_date8_0_, alert0_.environment as environm9_0_, alert0_.host as host10_0_, alert0_.nna as nna11_0_, alert0_.publisher as publish12_0_, alert0_.start_date as start_d13_0_ from alert alert0_ where alert0_.code=? and (alert0_.end_date is null)
Hibernate: select nextval ('alert_seq')
Hibernate: select nextval ('alert_seq')
от остального контроллера:
Hibernate: select alert0_.id as id1_0_, alert0_.agent_info as agent_in2_0_, alert0_.alert_info as alert_in3_0_, alert0_.alert_name as alert_na4_0_, alert0_.cluster as cluster5_0_, alert0_.code as code6_0_, alert0_.criticality as critical7_0_, alert0_.end_date as end_date8_0_, alert0_.environment as environm9_0_, alert0_.host as host10_0_, alert0_.nna as nna11_0_, alert0_.publisher as publish12_0_, alert0_.start_date as start_d13_0_ from alert alert0_ where alert0_.code=? and (alert0_.end_date is null)
Hibernate: insert into alert (agent_info, alert_info, alert_name, cluster, code, criticality, end_date, environment, host, nna, publisher, start_date, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Любая помощь или предложения, пожалуйста
Спасибо