Код: Выделить всё
Spring Boot 3.5.3 (Hibernate 6.6.18.Final)
Previously: Spring Boot 2.0.6 with Hibernate 5.x — updates worked.
Database: PostgreSQL 13
< /code>
entity < /h2>
@Entity
@Table(name = "tbl_employees")
public class EmployeeEntity {
@Id @GeneratedValue
private Long id;
private String email;
private String firstName;
private String lastName;
// getters/setters omitted
}
< /code>
контроллер < /h2>
@PostMapping("/employees")
public ResponseEntity createOrUpdate(@RequestBody EmployeeEntity emp) {
EmployeeEntity saved = repository.save(emp);
return ResponseEntity.ok(saved);
}
< /code>
logs до < /strong> Migration (Hibernate 5.x)-Обновление Улучшается: < /h2>
2025-07-08 14:44:29.238 DEBUG … Flushed: 0 insertions, 1 updates, 0 deletions to 1 objects
2025-07-08 14:44:29.239 DEBUG … Listing entities:
EmployeeEntity{firstName=null, lastName=null, id=0, email=null}
< /code>
→ SQL Update Tbl_employee set ... где id =? < /code> выполнено успешно < /p>
logs после < /strong> migration (hibernate 6.x)-неудача с null id: < /h2>
Подробнее здесь: [url]https://stackoverflow.com/questions/79698688/hibernate-6-6-spring-boot-3-assertionfailure-null-id-when-saving-updating[/url]