2tier application using Hibernate

I got involved in new project in Janury. The goal was to develop new version of existing application. It must be 2tier RCP and it must be albe work over many databases (used by 16 banks, political reasons).

We decided to use Eclipse RCP and Hibernate.
Eclipse RCP work’s fine. SWT and JFace makes gui development quite easy.
But using Hibernate in 2tier application brings many difficulties:

  • Session slows down when contains many (hundreds) objects
  • You cannot use Session after you got some error on it
  • There are some bugs in HQL that make advanced usage quite difficult

See Hibernate in 2 tier application discussiong Is it Possible to Combine Hibernate + Swing?????.

After 5 months (I became the project leader meanwhile) we eneded up with 2,5 tier design:

  • use DAO classes to load light objects displayed in views (eg. load, initialize and close session in getChildren methods)
  • use SQL and HQL for batch updates where possible
  • use session per editor, load with LockMode.UPGRADE
  • use Maps instead of querying database
  • divide batch processing into small part, each in new session and transaction or use StateLess session

Advanced Hibernate bugs

PS: next version must be 3-tier application.

5 Responses to “2tier application using Hibernate”

  1. ravi kumar Says:

    how we use the JSF andhibernate with DAO

  2. How to deal with complex object graphs and Hibernate « When IE meets SE Says:

    [...] 2tier application using Hibernate [...]

  3. Nadja Says:

    Hello Lukas,

    I was asked to combine hibernate and swing for a school project and I’m a little short of solutions about what to do and there’s not much documentation about the subject.. I would like to see an example of your work..
    if you can help me with anything I’ll appreciate.
    regards.

  4. Maximus Says:

    I would like to see a continuation of the topic

  5. Udo Says:

    Hi Lukas,

    had also spend some times and nerves to get hibernate working with swing.
    I switched to OJB (http://db.apache.org/ojb/) 3 years ago and it was a good
    decision - a stable and well designed framework.

    Unfortunately, it seems that nobody evolve OJB:-(

Leave a Reply