Is there a way to configure or override the JPA @Version annotation to use Strings (UUID's) ?
I have a simple example of optimistic concurrency working using int as per examples
int version
@Version
Public Integer getVersion ()
return version;
...
We have a requirement to look at using GUID's for versioning instead (at the moment held in a Postgres db as a character varying 100).
I'll be honest I've got my example working a short while ago and haven't dug around too much yet. My first attempt was a bit of a hopeful shot in the dark -
String version
@Version @GeneraedValue(generator="system-uuid")
Public String getVersion ()
return version;
...
basically I think this is the way you use UUID for primary keys. I guess if this was going to work they would have documented this!
I'm sure I've heard it is possible though although my initial googling han't come up with anything so I thought I'd ask if anyone had done this before or could point me in the direction of a rough approach (I'm assuming it would be a bit deeper than my simple attempt) ?