Why is converting it to a string ugly? If you're planning on storing it in a single column in the DB, then there's no alternative. If you want to separate the URI into its five component parts and store then separately, then yes, use a UserType. But if you're just storing the string, then converting it to a string is perfect, and not ugly at all.
The only downside to this is that there's no way to set the contents of the URI after it has been created. So you'll have to write a method for hibernate's use everywhere you have a URI property: set<fieldname>(String uri). But you can stick with the preferred set<fieldname>(URI uri) for your API code.
|