I don’t understand all the hype around annotation, and I prefer HBM for the following reasons (these reasons cancel out such flaws as typos, compile-time checking for me):
- Relative Concern / Immediate Responsibility: With HBM, you have all ORM-related stuff in HBM. The essence and logic of the domain (regardless of the structure of the table) in the java class. Your DB and java class can be changed independently (only HBM needs to be updated).
- Your code is not cluttered with annotation. I prefer to just look at the domain logic. Annotations add a lot of noise.
If the HBMs are well organized (one HBM per java class, sequential naming), it becomes easy to navigate between them. The Junit test and some discipline eliminate the need to check compile time. As for defaults, I think that if sleep mode may not work at all with annotations, it should be able to work without XML at all (conceptually - I don’t know if this is a reality)
Raghu
source share