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.

Leave a Reply

Your email address will not be published. Required fields are marked *