For generation id's of entities application uses trigger. So, for assigning generated values to entities we use constructions like this:
@Id
@Column(name = "INVOICE_ID")
@GeneratedValue(generator = "trigger")
@GenericGenerator(name = "trigger", strategy = "org.hibernate.id.SelectGenerator")
private Long invoiceId;
@Column(name = "INVOICE_AMOUNT")
@NaturalId(mutable = true)
private Double invoiceAmount;
SelectorGenerator
requires to use @NaturalId
for some field, which should has(logically) unique value. But some tables don't have anyone field which has all unique values. SelectGenerator
doesn't support multiple natural id's. How can we get round this situation?