0

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

BAKHALED Ibrahim
  • 473
  • 1
  • 7
  • 19
  • Check the top answer for this - https://stackoverflow.com/questions/12495399/how-to-use-a-sequence-generator-for-a-non-id-field. – Chhaganlaal Jun 02 '23 at 05:21

0 Answers0