i'm new hibernate.
1) don't quite understand why need specify o/r mapping relationship in *.hbm.xml file or add annotations "one-to-one", "one-to-many", etc in databeans. must have them? how o/r mapping relationship work behind scene?
2) difference between adding relationship *.hbm.xml , databean annotation? should both? advantages , disadvantages each of them?
1.
you not need *.hbm.xml
files. there plenty of examples on web using jpa annotations. there orm implementations not need configuration , use database create classes (particularly in dynamically typed languages) hibernate not 1 of them.
hibernate looks @ class , configuration (jpa annotations and/or xml) , see if entity exists , matches correctly (depending on configuration).
2.
the advantage using xml domain objects in theory less coupled in practice not worth effort because annotations (jpa) decoupled themselves. if annotations packaged hibernate , proprietary hibernate more of issue. people don't annotations.
the huge advantage of using jpa annotations in theory can switch jpa implementations not case hibernate xml files. in practice switching jpa implementations midstream non trivial task.
Comments
Post a Comment