+ "')) order by i.date DESC LIMIT " + limit;
+ "')) order by i.date DESC, i.item_id ASC LIMIT " + limit;
    public Collection getItemsForUser(String username, int limit)            throws IndexOutOfBoundsException {        // System.out.println("hallo!");        // Object[] o = { username, username/*, new Boolean(true) */};        // net.sf.hibernate.type.Type[] t = { Hibernate.STRING, Hibernate.STRING        // /*, Hibernate.BOOLEAN*/};        //"from FeedSubscriber f where f.user.username like ? and        // f.channel.items in 16"        //"from Item i, FeedSubscriber f, UserReadItem uri where i in (Select        // f.channel.items where f.user.username like ?)"        //return getHibernateTemplate().find("select DISTINCT i.id from Item i,        // UserReadItem uri where i in (select elements(f1.channel.items) from        // FeedSubscriber f1 where f1.user.username like ?) and i.id =        // uri.item.id and uri.user.username like ? and uri.read = ?",o,t);        //return getHibernateTemplate().find("select * from Item as i LEFT        // OUTER JOIN UserReadItem as uri ON (i.id=uri.item.id)");        //        String query = "select i.item_id AS {item.id} from items as i LEFT        // OUTER JOIN usersreaditems u ON (i.item_id = u.item_id AND u.username        // like 'vec')";        //     and(item0_.ITEM_ID in(select items4_.ITEM_ID from FEEDSUBSCRIBERS        // feedsubscr2_, CHANNELS channel3_, ITEMS items4_ where        // feedsubscr2_.CHANNEL_ID=channel3_.CHANNEL_ID and        // channel3_.CHANNEL_ID=items4_.CHANNEL_ID and ((feedsubscr2_.username        // like 'vec' ))))        if (limit > this.upperLimit) {            log                    .warn("Someone want more see more Items than specified in this.upperLimit!");            log.warn("Cut down " + limit + " to " + this.upperLimit);            limit = this.upperLimit;        }        String query = "select {i.*}, {uri.*} from Items as i LEFT OUTER JOIN usersReadItems as uri "                + "on (i.item_id=uri.item_id and uri.username='"                + username                + "') "                + "where i.item_id in "                + "(select items4_.ITEM_ID from FEEDSUBSCRIBERS feedsubscr2_, CHANNELS channel3_, ITEMS items4_ "                + "where feedsubscr2_.CHANNEL_ID=channel3_.CHANNEL_ID and channel3_.CHANNEL_ID=items4_.CHANNEL_ID and "                + "(feedsubscr2_.username like '"                + username                + "')) order by i.date DESC LIMIT " + limit;        try {            java.util.Collection c = this.getSession().createSQLQuery(query,                    new String[] { "i", "uri" },                    new Class[] { Item.class, UserReadItem.class }).list();            log.debug("Resultset: " + c.size());            return this.simplifyCollection(c);        } catch (DataAccessResourceFailureException e) {            // TODO Auto-generated catch block            e.printStackTrace();        } catch (HibernateException e) {            // TODO Auto-generated catch block            e.printStackTrace();        } catch (IllegalStateException e) {            // TODO Auto-generated catch block            e.printStackTrace();        }        return null;        //return getHibernateTemplate().find("select {i.*}, {uri.*} from Item        // as i LEFT OUTER JOIN i.usersReadItem as uri on (i.id=uri.item.id and        // uri.user.username='vec' )where i in (select        // elements(f1.channel.items) from FeedSubscriber f1 where        // f1.user.username like 'vec') order by order by i.date DESC LIMIT        // 10");    }