Anyone come across this issue. We have a PK field that is either application generated or Trigger generated. Depending on the type, the generation of the ID is different. For instance, if it is type A then the application will assign the value. But if it is type B, then a Before Insert trigger will assign the value.
Currently we just have
@Entity
public class User
@Id
public
String userId;
That works for the Type A situations, but for inserting Type B objects you get
org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save()
thrown
Now, I really don't want to have to implement our own IdentifierGenerator class to make this work, I would assume there must be a way. I was going to assign the userId with a fake "0" but then that would make the trigger not operate since it has an
if .userId ISNULL
and if it is null, then it runs the assignment.
This is a legacy database that is not going to change, and there are no surrogate keys.
Thanks guys
Mark