Hibernate supports mapping UUIDs to "binary" fields (by default, binary in MySQL, varbinary in H2, for example). This is very convenient, but not as much when creating DbUnit datasets: DbUnit allows putting base64-encoded values of the binary data as strings into the datasets, but it's not so convenient for UUIDs (after all, your tests might deal with the same UUIDs, and encoding-decoding is a hassle).
One proposal to solve this is to introduce special syntax in order to detect hex-stringified UUIDs, e.g.:
<some_table uuid="uuid'2f3f866c-d8e6-11e2-bb56-50e549c9b654'" another_column="blah"></some_table>
This would allow the user to explicitly mark their data as UUIDs (in case it's mapped to a binary, varbinary or a longbinary field - basically, those that are currently handled by the BytesDataType class), while still having them readable and easily maintainable.
Attached you can find the patch that introduces this functionality by the means of the UuidAwareBytesDataType class.
Ah, the XML tags got stripped out. Sigh. Anyway, the proposal for the syntax was:
<some_table uuid="uuid'029afe42-d8e7-11e2-aca1-50e549c9b654'" another_column="blah"/>
More changes and more tests (first version doesn't have changes to the typeCast() method, so it doesn't work in compare, for example).
More changes and more tests (first version doesn't have changes to the typeCast() method, so it doesn't work in compare, for example).
Sorry for spam, SF wasn't quite working.
So, I reviewed my patch again and removed some redundant code. Attaching v3 of the patch.
Confirmed to be working on current trunk (2.4.10-SNAPSHOT).
Can this please be part of the next release?
Hi, thanks. Applied for next release after 2.4.9.
Users won't know about your feature unless doc updated. Will you provide a patch for a doc update please?
Added a section to the FAQ.
Thanks!