Pinaki Poddar wrote:
>
> So try something like:
> Query query = em.createNativeQuery(sb.toString());
> Object result = query.getSingleResult();
> InformerRow ir = new InformerRow();
> ir.s5 = ((Number)result).intValue();
>
>
Wow! It works! Great!
So, please can you tell me why this didn't work:
Query query = em.CreateNativeQuery(sb.toString(), InformerRow.class);
InformerRow ir = (InformerRow)query.getsingleResult();
and my InformerRow class:
public class informerRow{
//...
//...
private long s4;
private Number s5;
public InformerRow(){
super();
}
public InformerRow(Number s5){
super();
this.s5 = s5;
}
public InformerRow(Number s4){
super();
this.s4 = s4;
}
//public getters and setters for s5 and s4
}
The same thing for s4 worked fine when query was: "select count(t.someField
from schema.table t where ...)"
I' don't understand why... :(
--
View this message in context:
http://n2.nabble.com/Can-t-map-AVG-sql-field-to-class-tp1562523p1576019.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.