I am getting following error for my code
BasicPropertyAccessor - expected type: java.lang.String, actual value: java.lang.Character
MyBean
Code:
public class GuestLog
{
private java.lang.String rESNO ;
private java.lang.Integer aGENTID ;
public void setRESNO (java.lang.String _rESNO )
{
this.rESNO = _rESNO;
}
public java.lang.String getRESNO ()
{
return this.rESNO ;
}
public void setAGENTID (java.lang.Integer _aGENTID )
{
this.aGENTID = _aGENTID;
}
public java.lang.Integer getAGENTID ()
{
return this.aGENTID ;
}
}
My SQL Statement
Code:
StringBuilder hsql = new StringBuilder(
"SELECT rESNO as RESNO , aGENTID as AGENTID from mytable");
SQLQuery query = sessionFactory.getCurrentSession().createSQLQuery(
hsql.toString());
query.setResultTransformer(Transformers.aliasToBean(GuestLog.class));
List<GuestLog> result = query.list();
As soon as i add following, the query works
Code:
query.addScalar("RESNO", Hibernate.STRING);
query.addScalar("AGENTID ", Hibernate.INTEGER);
I really dont like this idea of adding scalar to all the columns, any work arounds