HqlQueryTranslator extends
        AbstractHibernateQueryTranslator<String, String, String> implements
        QueryTranslator<String, String, String> { protected String string(Object o) { if (o instanceof Object[]) { return "[" + Joiner.on(",").join( Lists.transform(Arrays.asList((Object[])o), toString) ) + "]"; } else if (o instanceof String) { return "\"" + ((String)o).replace("\"", "\\\"") + "\""; } else if (o instanceof Character) { return "'" + (o.toString().replace("'", "\\'")) + "'"; } else if (o instanceof Date) { return string(dateFormat.format((Date)o)); } return o.toString(); } HqlQueryTranslator(HibernatePropertyResolver propertyResolver,
            BoxMaker boxMaker,
            ContainsExpressionHandler<String> containsExpressionHandler);  HqlQueryTranslator(HibernatePropertyResolver propertyResolver,
            BoxMaker boxMaker);  HqlQueryTranslator(HibernatePropertyResolver propertyResolver); @Override String eq(String fieldName, Object value); @Override String ne(String fieldName, Object value); @Override String lt(String fieldName, Object value); @Override String lte(String fieldName, Object value); @Override String gt(String fieldName, Object value); @Override String gte(String fieldName, Object value); @Override String between(String fieldName, Object from, Object to); @Override String in(String fieldName, Object[] values); @Override String notIn(String fieldName, Object[] values); @Override String isNull(String fieldName); @Override String notNull(String fieldName); @Override String isEmpty(String fieldName); @Override String notEmpty(String fieldName); @Override String within(String xFieldName,
            String yFieldName, Box<N> box); @Override String and(String... subqueries); @Override String or(String... subqueries); @Override String order(String fieldName, Order o); @Override String order(String... orders); @Override String translateProjection(Query<T, R> query); static final String TIMESTAMP_FORMAT; }
@Test public void string_String() { assertEquals("\"test string\"", translator.string("test string")); }
@Test public void string_String_quotes() { assertEquals("\"\\\"test\\\" string\"", translator.string("\"test\" string")); }
@Test public void string_Character() { assertEquals("'a'", translator.string('a')); }
@Test public void string_CharacterQuote() { assertEquals("'\\''", translator.string('\'')); }
@Test public void string_Date() { Calendar c = Calendar.getInstance(); c.set(Calendar.YEAR, 2012); c.set(Calendar.MONTH, 2 - 1); c.set(Calendar.DATE, 21); c.set(Calendar.HOUR_OF_DAY, 14); c.set(Calendar.MINUTE, 34); c.set(Calendar.SECOND, 25); assertEquals("\"2012-02-21 14:34:25\"", translator.string(c.getTime())); }