I would like to create a mapping service using JPA. The mapping is simple, I have one key (String) for one value (Long). The keys are computed values (so it cannot be autogenerated) and are unique. The only operations that will be executed is findById(String key) and save(MyMapping mapping). What I want is, when I save a new mapping, I just need to give the key, and the value would be autogenerated using autoincrement.
What is the best way to implement this ? Is there a @GeneratedValue for value columns?
JPA version : jakarta.persistence:jakarta.persistence-api:2.2.3
My mapping entity :
@Entity
public class MyMapping {
@Id
String key;
Long value; // must be unique and autoincremented value
}