[hibernate-dev] [ORM/OGM] String-typed version properties

Gunnar Morling gunnar at hibernate.org
Tue Nov 26 11:14:39 EST 2013


Thoughts, anyone? Steve?

Thanks,

--Gunnar



2013/11/21 Gunnar Morling <gunnar at hibernate.org>

> All,
>
> I'm working on supporting on the CouchDB backend for OGM, and more
> specifically on integrating the optimistic locking functionality which is
> built into CouchDB [1].
>
> For that purpose, each CouchDB document has a defined field "_rev" which
> is a UUID and is updated on the server-side upon each write. So I thought I
> could map this attribute like this:
>
>     @Generated //this prop. needs to be read back value after writes
>     @Version //this prop. is used for optimistic locking
>     String _rev;
>
> But this gave me a CCE since @Version is not allowed on Strings
> (org.hibernate.type.StringType is no VersionType).
>
> Looking around, I found BinaryType which looks like what'd I need for
> Strings, there is also a note mentioning basically the same use case case
> [2]. If I register a custom type derived from StringType with an equivalent
> implementation of the VersionType contract, I get the behavior I need.
>
> Does anyone see a problem with making o.h.t.String a VersionType in this
> way (i.e. it'd only support DB-generated values)?
>
> Thanks,
>
> --Gunnar
>
> [1] https://hibernate.atlassian.net/browse/OGM-392
> [2] "only known application of binary types for versioning is for use with
> the TIMESTAMP datatype supported by Sybase and SQL Server, which are
> completely db-generated values"
>
>


More information about the hibernate-dev mailing list