Hi,

I need to implement the following type of query with Appfuse. Not the
object does not need to be persisted 

 

SELECT id, columnA,SUM(ColumnB),COUNT(*) FROM Table 
GROUP BY ColumnA;

 

My Pojo has the properties

id

columnA

columnB

count

For the count(*) I have just a hibernate property count defined.

 

/**

 * @hibernate.property 

 * @struts.form-field 

 */ 

public Integer getCount() {

                return this.count();

 }

 

I used Appgen to generate all the classes, pages etc.

 

In the hibernateDao class, I use the example with criteria and
restrictions as follows:

......

 public Object doInHibernate(Session session) throws HibernateException
{

                                Example ex =
Example.create(obf)/*.ignoreCase().enableLike(MatchMode.ANYWHERE)*/;

                                return
session.createCriteria(myPojo.class)

 
.add(ex)

 
.setMaxResults(100)

 
.setProjection( Projections.projectionList()

 
.add(Projections.sum("columnB"))

 
.add(Projections.rowCount(), "count" )

 
.add(Projections.groupProperty("column")))

 
.list();

                             }

                        };

                       return
(List)getHibernateTemplate().execute(callback);

......        

With the log4j sql set to DEBUG, The generated query looks ok. However
when the page is rendered, I get the error:

 

javax.servlet.jsp.JspException: Error looking up property "id" in object
type "[Ljava.lang.Object;".
                    at
org.displaytag.render.TableWriterTemplate.writeTable(TableWriterTemplate
.java:161)

 

It seems like it can't iterate through the list, but I just can't get
the solution for this. Any assistance is highly appreciated

 

Travers

 

 

 

 

Reply via email to