I would like to execute a function every x time to update some values in the database, without changing the ids of the existing ones. It is possible that values that I already have and that I would not like to duplicate can be vegetated.
What I want to achieve is not to duplicate the values or have to delete them (I want to keep the id)
@Entity
@EntityListeners(AuditingEntityListener::class)
@SQLInsert(sql="INSERT IGNORE INTO countries(country_code) VALUES(?)")
@Table(name = "countries")
class Country (
@Column(unique=true)
var countryCode: String? = null,
){
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
var id: Long = 0
}
This is the error that I get when I do a saveAll and some value is duplicated
Caused by: org.hibernate.HibernateException: The database returned no natively generated identity value
I have tried, without the @SQLInsert and without the countryCode being unique