Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: all connections in pool are sleepy!

  1. #11
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    The easiest way is probably the HibernateCallback, that way you can leave most of the code as is. You only need to wrap it in a callback (as my example) and remove the getSession call (replace it with session).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  2. #12
    Join Date
    Nov 2005
    Posts
    14

    Default

    I have determined that the piece of code that is accessed about 75% over everything else, is our "view article" function (think news service). It looks like:

    Code:
    public Object getByField(String fieldName, String fieldValue) throws DaoServiceException {
      try {
        String query = "from myco.dom.Article as a where " + fieldName + " = '" + fieldValue + "'";
        query += " order by " + this.orderByColumn;
        List objs = getHibernateTemplate().find(query);
        if(objs != null && objs.size() > 0) {
          Article art = (Article)objs.get(0);
          return getHibernateTemplate().load(Article.class, new Integer(art.getId()));
        } else {
          return null;
        }
      } catch(Exception e) {
        throw new DaoServiceException(e);
      }
    }
    Do you see any possible db leaks there?

    Thanks

  3. #13
    Join Date
    Sep 2004
    Posts
    1,086

    Default

    A lot of things could be said about that piece of code, but there is no connection leak in it.

  4. #14
    Join Date
    Nov 2005
    Posts
    14

    Default

    This is why I pay our developers so much money....

    (Ok, so I won't admin it's mine!)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •