This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
In my opinion from a maintenance perspective it is not feasible to have a mix of annotations and mappings file. I haven't seen developers build a liking to documentation yet and just imagine how difficult it would be for a newly hired developer to understand the mappings involved.
Leaving maintenance aside... you have the perfect example so I recommed that you use your fav IDE and start coding. It shouldn't take you more than a couple of hours to check it out for yourself and then share it with the rest of the ranchers. They will be grateful to you. [ October 04, 2007: Message edited by: Shailesh Kini ]
Joined: Nov 02, 2002
Shailesh, Only after trying out I recognized hibernate's problem. Still uncertain about other alternatives, I raised this question in the forum. Basically, when I do this I get the "java.lang.ExceptionInInitializerError" error and the detailed stackTrace specfies that "Id" needs to be specified for the subclass (which B).Since the inheritence strategy used is "table per subclass"(joined subclass), hibernate does not need to know about the PK for B. This gives me a feeling that hibernate is not recognizing B's parent class.
If I used mappings only, then the mapping for A would contain the joined-subclass element. If I used annotations only, then A would have @Inheritence(strategy=InheritanceType.JOINED). Since this information is missing by mixing annotations and mapping, hibernate is confused!
I guess this is what they are trying to convey in the docs:
"You cannot mix configuration strategies (hbm vs annotations) in a mapped entity hierarchy either."
I am not sure... :-)
Any thoughts is very much appreciated.
Joined: Oct 17, 2001
I am not a hibernate expert but... here are some of my thoughts.
Entity mapping can be done in 2 different ways... 1. Have a hbm mapping file. 2. Using annotations.
I am not sure which takes precedence of the other but imagine hibernate allowed both strategies to co-exist. In this case what if i have different mapping rules in hbm and annotations. Hibernate api developers would then have to figure out which rules to apply based on whether they have hbm or annotations.
Annotations can be applied at compile time, runtime etc... hbm files on the other hand have to be parsed at runtime. It can become increasingly complex to using both approaches together.
Maybe other ranchers can think of some more reasons.