Support for UUID
kutabale opened this issue · 5 comments
Is there a way to support UUID as primary keys.
Do you mean DB generated, or app generated? Neither is supported out of the box, but the latter should be relatively easy to add by yourself.
UUID as PK is suitable for applications that keep the same schema in multiple databases as it guarantees uniqueness across them. However, that's not a very efficient solution. Reladomo provides the ability to address multiple databases with the same schema without confusing rows that have the same PK using the "source attribute" concept. That way, you can use a simple integer for a PK, which is around 10x more efficient than a UUID (storage, comparison, etc).
Can you point to some documentation or at some example on how to add uuid to the model and or how to use "source attribute"?
You'll need to do the following with a source attribute:
- Put the attribute declaration before other attributes like this in the object xml: https://github.com/goldmansachs/reladomo/blob/master/reladomo/src/test/reladomo-xml/TinyBalance.xml#L26
- You can use String or int for the type
- Create a connection manager that implements IntSourceConnectionManager or ObjectSourceConnectionManager. This typically contains a
Map<sourceAttribute, XaConnectionManager>
. - When using finders, always specify the source attribute (e.g.
TinyBalanceFinder.acmapCode().eq("foo")
) - Before doing an
insert()
make sure the source attribute is set on the object
Thank you for your answers, few more questions:
Is there a notion of interception similar to Interceptor in Hibernate?
We are looking to use the library because of its bi-temporal chaining, how does source attribute integrates with bi-temporal data?
There is an update listener. See the advanced docs slide 17.
Source attribute is an orthogonal concept to bi-temporal data: they work together without interference.