I need to have an event_number column in my events table, which can uniquely identify each row, but this column is not the @Id of the table. Each event_number must follow some format like EVENT100001,EVENT100002,...
I went through @GeneratedValue
annotation and found that this only can be used with @Id columns. But then found this answer but not sure whether it causes any race conditions.
Is there any cleaner way of doing this? Here is my entity
@Entity
@Table(name = "events")
public class Event {
@Id
@Access(AccessType.PROPERTY)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
@Column(name = "event_number", nullable = false, unique = true)
private String eventNumber;
}