Menu

#178 Special dataset syntax for UUIDs mapped to binary fields

2.5.0
closed-accepted
None
5
2014-04-20
2013-06-19
No

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.

1 Attachments

Discussion

  • Timur Strekalov

    Timur Strekalov - 2013-06-19

    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"/>

     
  • Timur Strekalov

    Timur Strekalov - 2013-06-20

    More changes and more tests (first version doesn't have changes to the typeCast() method, so it doesn't work in compare, for example).

     
  • Timur Strekalov

    Timur Strekalov - 2013-06-20

    More changes and more tests (first version doesn't have changes to the typeCast() method, so it doesn't work in compare, for example).

     
  • Timur Strekalov

    Timur Strekalov - 2013-06-20

    Sorry for spam, SF wasn't quite working.

    So, I reviewed my patch again and removed some redundant code. Attaching v3 of the patch.

     
  • Frederik van Hövell

    Confirmed to be working on current trunk (2.4.10-SNAPSHOT).

    Can this please be part of the next release?

     
  • Jeff Jensen

    Jeff Jensen - 2014-04-19
    • status: open --> closed-accepted
    • assigned_to: Jeff Jensen
    • Group: Next_Release --> 2.4.10
     
  • Jeff Jensen

    Jeff Jensen - 2014-04-19

    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?

     
  • Jeff Jensen

    Jeff Jensen - 2014-04-20
    • Release: --> 2.5.0
     
  • Timur Strekalov

    Timur Strekalov - 2014-04-20

    Added a section to the FAQ.

    Thanks!

     
MongoDB Logo MongoDB