To give an idea why I needed 5KLoC for such a simple model, here is a detailed analysis of Keyword.java:
LoC | Used by |
---|---|
43 | Getters and setter |
40 | XML Import/Export |
27 | Model |
27 | equals()/hashCode() |
21 | Hibernate mapping with annotations |
14 | Imports |
2 | Logging |
174 | Total |
As you can see, boiler plate code like getter/setters and equals() need 70LoC or 40% (48% if you add imports). Mapping the model to XML is more expensive than mapping it to a database. In the next installment, we’ll see that this can be reduced considerably.
Note: This is not a series of articles about flaws in Hibernate or the Java VM, this is about the Java language (ie. what you type into your IDE and then compile with javac).