JAW Speak

Jonathan Andrew Wolter

Archive for the ‘hibernate’ tag

Using Hibernate UserType’s for oddly formatted legacy tables (with tests)

with 2 comments

Reading time: < 1 minute

If you are using Hibernate with an existing (ahem, “creative”) database schema sooner or later you will be stuck with a field that Hibernate can’t parse. Say there is a Dimension column which stores the integer dimensions as a string "003X001X010". That would be 3 by 1 by 10 units.

You can implement UserType to transparently convert a proprietorially formatted field into first class objects of your choice.

And you can do it in a testable manner.

I’ll show the tests first, then the custom UserType. Right after the bump. (Click the post permalink to read the rest).

Read the rest of this entry »

Written by Jonathan

November 10th, 2008 at 1:23 am

Posted in code, java

Tagged with