I need to generate and ID for non-primary key for oracle, and I'm stuck about it. I tested GeneratedValue, SequenceGenerator and Genereted as I read that GeneratedValue works only for @Id property, I've seen a bunch of articles and questions about this (like this https://stackoverflow.com/questions/277630/hibernate-jpa-sequence-non-id) but nothing worked for me except the generating and ID using UUID but that's not how I want it. Let's cosider I have this entity
@Entity
@Table
public class ClassA {
@Id
private Long id;
private Long seq_val;
// Getters & Setters
}
What I need is that every time the data gets saved to databse a new key gets generate in seq_val Please anyone has an example