This is an interesting question as I've come across something similar. Instead of concatenation, I was trying to perform some mathematical functions on the properties from a queried Object:
Code:
select obj.a, obj.b, (obj.a + obj.b) from Object obj
This fails from Hibernate, so what I've done is include the calculation in my DAO layer. So my Business Layer will see a List that has a, b, and (a+b).
a little code snippet from my DAO
Code:
Iterator it = queryresultlist.iterator();
while(it.hasNext()) {
List newvallist = new ArrayList();
a = 0;
b = 0;
Object[] vals = (Object[])it.next();
for( int i=0; i< vals.length; i++) {
newvallist.add(vals[i]);
if( i == 0 ){
a = new Integer( vals[i].toString() ).intValue();
}
if( i == 1 ){
b = new Integer( vals[i].toString()).intValue();
}
}
Integer tot = new Integer( (a+b) );
newvallist.add(tot);
newqueryresultlist.add(newvallist.toArray());
}
return newqueryresultlist;
IMHO, if you haven't learned about DAO as part of a design pattern, you really should search in this forum for DAO threads... very enlightnening. It will make your code much more portable and flexible.