i'm fairly new to Java and Hibernate. At work we are developing a medium sized, formprocessing J2EE web application using Spring, Hibernate, JBOSS and so on. What is the correct approach using Hibernate? Should i create first a class diagram and the map it using hibernate to DB Tables or should i first model the DB Tables and then map it to Hibernate Entities? Or does it depend? If it depends than on what? Has either of this approaches drawbacks against the other? Is it possible to map "any" class diagram to a DB using Hibernate 4?
Both approaches are correct, but used in different situations.
But I repeat, both approaches are valid, if you are more DB engineer than Java programmer, you wold probably do 2) because it might be more natural to you. I as a Java programmar do (almost) always 1)...
You can the same results with both approaches and in both you have to think about, what will hibernate generate for you...
It doesn't make any difference: either is mappable to the other, but you need to be aware of both (the ORM impedance mis-match).
If you're doing greenfield development, IMO, go from class diagram => DB tables; it's easier to think in classes. In general, rational class structures map nicely to DB tables, but keep efficiency in mind (the "be aware" part).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With