About This Blog

This blog contains some information about Java programming strongly connected to making web pages, and JEE applications.

8 July 2008 - 21:27Wicket project nearly finished

There pass some time from my last writing here, there is no one, simple reason for that - maybe the most importat was that I went from theory to the practice with my Wicket skills. Previous posts were rather theroretical, books based news  - now my knowledge of the Wicket stuff is much more wide. In March company I work for started project which was related to car parts advertisements, now the project grows to quite nice car portal. There are advertisement section, questions and answers (or forum if you like the difference is subtle), picture gallery, user inbox stuff, full i18n.

All is powered by Wicket, Hibernate, Spring, search job are done by Hibernate Search (great collection indexing feature), lot of data is cached  by Ehcache. There are also plans of use Databinder, Terracotta and even Scala if my friend and great co-worker Tomek teach rest of the team this fabulous language.

Most important - link to the project http://www.auxto.pl/ - this is Polish version, but soon I think we launch others.

Thanks to the team Marcin, Tomek and Paweł - great work gentelmans :)

No Comments | Tags: Lucene, Wicket, hibernate, search, spring

3 January 2008 - 14:13Hibernate in Spring

Probably most people use getHibernateTemplate() (extends HibernateDaoSupport) when invoking Hibernate in Spring - it's very good option for most cases, but for beginnings there are some of hidden features, which are used in different way in pure Hibernate. So two of them I have to use today - first was narrowing results when using Criteria - it's very simple when using HibernateTemplate:

public List<QueueElement> getObjectsFromQueue(int first, int count) {
    return getHibernateTemplate().findByCriteria(DetachedCriteria.forClass(QueueElement.class), first, count);
}
 

Using this method we get nicely narrowed results for a given class. The second example considers object counting for given Criteria:

public int getQueueSize() {
    return (Integer) getHibernateTemplate().findByCriteria(DetachedCriteria.forClass(QueueElement.class)
        .setProjection(Projections.rowCount())).get(0);
}

It's very simple way to get rows counted without using Hibernate HibernateCallback and uniqueResult() method, as we can see in older example:

public int getConsumersSize() {
    return (Integer) getHibernateTemplate().execute(new HibernateCallback() {
        public Object doInHibernate(Session session) throws HibernateException, SQLException {
            return session.createCriteria(Consumer.class)
                .setProjection(Projections.rowCount())
                .uniqueResult();
            }
    });
}

No Comments | Tags: hibernate, spring