I need to interning string which result of my query.
Because my queries first field always contains "0" or "1", and every time its creates new String object.
And I want to use intern() on this string and use pool for saving some memory.
But my statement return a number:
SELECT CASE WHEN b.num >= 12 THEN 1 ELSE 0 END as "result",
ROUND (((b.num - 12)/12),2) AS "weight" FROM (SELECT sum(t.amount_inst) AS num
FROM MRCH_CARD t
....
So its result in java side was BigDecimal, not String:
But inside BigDecimal exists stringCache field with String value, and every time when I call that query as result of exection its creating new String Object with "1" or "0" value. How can I intern() that value to string pool? I tried that way, but I think this didnt work, because qr.getSingleResult() already created new String Object as stringCache field of BigDecimal:
Object[] tempResult = (Object [])qr.getSingleResult();
result.setResult(new BigDecimal(tempResult[0].toString().intern()));
result.setWeight(new BigDecimal(tempResult[1].toString().intern()));