Change implementation of ETag generation.

Use HQL queries for generation.
Also fix small bug when calculating the last translator for a document.
Switch hashable state method to use a StringBuffer instead of List<String>
Change translated document hash method implementation to use a single native SQL query.

Add tests for hash method.