Hello
Thanks for the greate tutorial
I'm experience the interesting issue if I change the id from Integer to UUID in File class in spring-data-jpa-auditing project :
@Id
@GeneratedValue (generator = "UUID")
@GenericGenerator( name = "UUID",
strategy = "org.hibernate.id.UUIDGenerator"
)
private UUID id;
The exception I'm getting is :
Caused by: org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint ["PRIMARY_KEY_2 ON PUBLIC.FILE(ID) VALUES (X'1797c3aded61453d891874d491356c9c', 1)"; SQL statement:
insert into file (created_by, created_date, last_modified_by, last_modified_date, content, name, id) values (?, ?, ?, ?, ?, ?, ?) [23505-197]]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
And I see two insert statements for File entity.
To reproduce, just change the id to be UUID with the annotations I've shown before ,tweak getter and seeter ,change from @PrePersist to @PostPersist :
public class FileEntityListener {
@PostPersist // @PrePersist
public void prePersist(File target) {
perform(target, INSERTED);
}
}
and run.
Can you think about the reason and possible solution ?
Thanks
Hello
Thanks for the greate tutorial
I'm experience the interesting issue if I change the id from
IntegertoUUIDinFileclass inspring-data-jpa-auditingproject :The exception I'm getting is :
And I see two insert statements for
Fileentity.To reproduce, just change the id to be UUID with the annotations I've shown before ,tweak getter and seeter ,change from
@PrePersistto@PostPersist:and run.
Can you think about the reason and possible solution ?
Thanks