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
- HQL delete in 3.1.3 bug (we use version 3.1.2)
- HQL insert into … select … statement problem due to lacking table aliases in select clause (we use sql directly)
- HQL update on classes using inheritance requires temporary tables when not necessary
PS: next version must be 3-tier application.
March 15th, 2007 at 1:26 pm
how we use the JSF andhibernate with DAO
June 19th, 2007 at 9:41 am
[...] 2tier application using Hibernate [...]
November 23rd, 2007 at 5:11 pm
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.
December 20th, 2007 at 12:18 pm
I would like to see a continuation of the topic
February 2nd, 2008 at 1:45 am
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:-(