You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Björn-Peter Tietjens <bj...@web.de> on 2008/10/09 22:41:49 UTC

Hibernate + HTML-Table

Hey there,

I want to execute a simple sql-count-query with a "group by" statement 
and display the result in a html-table...

something like:
            session = HibernateUtil.getSessionFactory().getCurrentSession();
            session.beginTransaction();
            String SQL_QUERY = "SELECT COUNT(*),Date FROM Person Group 
By Date";
            Query query = session.createQuery(SQL_QUERY);


What is the best way to manage that, not using too much fancy stuff...?

Cheers B

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Hibernate + HTML-Table

Posted by James Carman <ja...@carmanconsulting.com>.
Wicketopia has an example application that does what you want.  The
HomePage (which shows a sortable table) is here:

https://wicketopia.svn.sourceforge.net/svnroot/wicketopia/trunk/example/src/main/java/org/wicketopia/example/web/page/HomePage.java


On Thu, Oct 9, 2008 at 4:41 PM, Björn-Peter Tietjens <bj...@web.de> wrote:
> Hey there,
>
> I want to execute a simple sql-count-query with a "group by" statement and
> display the result in a html-table...
>
> something like:
>           session = HibernateUtil.getSessionFactory().getCurrentSession();
>           session.beginTransaction();
>           String SQL_QUERY = "SELECT COUNT(*),Date FROM Person Group By
> Date";
>           Query query = session.createQuery(SQL_QUERY);
>
>
> What is the best way to manage that, not using too much fancy stuff...?
>
> Cheers B
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Hibernate + HTML-Table

Posted by Michael O'Cleirigh <mi...@rivulet.ca>.
Hi Björn-Peter,

Have a look at DefaultDataTable which is part of the wicket-extensions 
module


|*DefaultDataTable 
<http://wicket.sourceforge.net/wicket-extensions/apidocs/wicket/extensions/markup/html/repeater/data/table/DefaultDataTable.html#DefaultDataTable%28java.lang.String,%20wicket.extensions.markup.html.repeater.data.table.IColumn%5B%5D,%20wicket.extensions.markup.html.repeater.util.SortableDataProvider,%20int%29>*(java.lang.String id, 
IColumn 
<http://wicket.sourceforge.net/wicket-extensions/apidocs/wicket/extensions/markup/html/repeater/data/table/IColumn.html>[] columns, 
SortableDataProvider 
<http://wicket.sourceforge.net/wicket-extensions/apidocs/wicket/extensions/markup/html/repeater/util/SortableDataProvider.html> dataProvider, 
int rowsPerPage)|

you put the Hibernate stuff into a service layer (so you can use the 
spring @Transactional annotation) and then have that called through your 
implementation of the SortableDataProvider.

The IColumn's define the columns that will appear in the table.

If you have a small number of results you could extract seperately and 
use the ListDataProvider (java.util.List list) to provide data for the 
table.

If you have a large data set you should implement your own version that 
pages through hibernate. add one of the toolbars to get this pagination 
functionality automatically. (dataTable.addTopToolbar (new 
NavigationToolbar()))

Regards,

Mike


>
>
> I want to execute a simple sql-count-query with a "group by" statement 
> and display the result in a html-table...
>
> something like:
>            session = 
> HibernateUtil.getSessionFactory().getCurrentSession();
>            session.beginTransaction();
>            String SQL_QUERY = "SELECT COUNT(*),Date FROM Person Group 
> By Date";
>            Query query = session.createQuery(SQL_QUERY);
>
>
> What is the best way to manage that, not using too much fancy stuff...?
>
> Cheers B
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org