@Entity@Sql( select= { @SqlSelect(debug=true,query="select user.user_id as userid,count(*) as total from user group by user.user_id") })public class SqlSelectDemo { Integer userid; int total; public Integer getUserid() { return this.userid; } public void setUserid(Integer userid) { this.userid = userid; } public int getTotal() { return this.total; } public void setTotal(int total) { this.total = total; }}
the type of the var userid is Integer.But change the method as setUserid(int userid).It will throw exception:Exception in thread "main" java.lang.NoSuchMethodError: cn.helphope.dao.pojo.SqlSelectDemo.setUserid(Ljava/lang/Integer;)V at cn.helphope.dao.pojo.SqlSelectDemo$$EntityBean$mysql._ebean_setField(SqlSelectDemo.java:1) at com.avaje.ebean.server.reflect.EnhanceBeanReflect$Setter.set(EnhanceBeanReflect.java:110) at com.avaje.ebean.server.deploy.BeanProperty.setValue(BeanProperty.java:530) at com.avaje.ebean.server.deploy.BeanProperty.readSet(BeanProperty.java:397) at com.avaje.ebean.server.query.SqlTreeNodeBean.load(SqlTreeNodeBean.java:204) at com.avaje.ebean.server.query.CQuery.readRow(CQuery.java:444) at com.avaje.ebean.server.query.CQuery.readBeanInternal(CQuery.java:475) at com.avaje.ebean.server.query.CQuery.readTheRows(CQuery.java:559) at com.avaje.ebean.server.query.CQuery.readCollection(CQuery.java:543) at com.avaje.ebean.server.query.CQueryEngine.findMany(CQueryEngine.java:88) at com.avaje.ebean.server.query.DefaultOrmQueryEngine.findMany(DefaultOrmQueryEngine.java:95) at com.avaje.ebean.server.core.OrmQueryRequest.findList(OrmQueryRequest.java:215) at com.avaje.ebean.server.core.DefaultServer.findList(DefaultServer.java:1053) at com.avaje.ebean.query.DefaultOrmQuery.findList(DefaultOrmQuery.java:491) at cn.helphope.dao.SqlSelectDemoDao.main(SqlSelectDemoDao.java:21)
Currently I'm not sure about this enhancement. I'd be interested to know/understand the value in supporting this.
Specifically, I'm not convinced that Auto boxing is consistent with the bean property spec (which is what is being followed when using "subclassing" as in the case above).
Said a different way, if you use "enhancement" rather than "subclassing" then you do not need to follow the bean spec and it will work (with the auto boxing).
Hmmm.
I'll close this - you need to reopen if you believe this is a defect.
You can use Enhancement (field access effectively) and otherwise you need to follow the java bean conventions.