Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have a couple of suggestions that may simplify or route around the problem, though I'm not answering your specific question about hbm.xml.</p> <p>1) You can manually generate your IDs. Leave off the <code>@GeneratedValue</code> and I believe you can just use Java's <a href="http://docs.oracle.com/javase/1.5.0/docs/api/java/util/UUID.html#randomUUID%28%29" rel="nofollow"><code>UUID.randomUUID()</code></a> to generate a RFC 4122 compliant UUID like Hibernate's <code>'uuid2'</code> generator. I haven't used that specific generator in Hibernate, but if all you want is a valid UUID, it seems like manually generating it might help you avoid some of the configuration dance.</p> <p>2) Personally I just store UUIDs (albeit for non-id columns) in PostgreSQL in varchar columns. I find when it comes time for database sleuthing, I'm cutting and pasting UUIDs from log files, and it makes it easier to query. When the UUID was stored as BINARY, it was impossible, which is why we changed them to varchar. We considered UUID columns but varchar makes so many things simpler and improves interoperability. It's trivial to encapsulate the String-to-UUID conversion in your Java class.</p> <p>Of course you may have to use the UUID column type for legacy reasons, or you might prefer it for performance reasons. At least one person has done a <a href="http://jochem.vandieten.net/2008/02/06/postgresql-uuids-and-coldfusion-1/" rel="nofollow">performance comparison of the two approaches</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload