Author | Message |
---|---|
kknaur
Posts: 540
|
Posted 14:57 Oct 16, 2010 |
In the reading from the Hibernate book, the authors mention being able to specify hibernate metadata mappings in an XML config file, but they also mention doing the same thing using annotations in the persistent java classes themselves. For the purposes of this class should we focus on the XML file method or should we also make note of the ability to make mappings using annotations? |
cysun
Posts: 2935
|
Posted 10:31 Oct 17, 2010 |
In this class we only cover mapping using the XML syntax. Annotation is the new (and somewhat standard way) of doing Hibernate mapping. I think at some point in the future we'll switch to using annotations in CS520, but I have not done it yet for several reasons: 1. I'm not fully convinced annotation is the better way. Personally I'd rather read an XML file that has all the mappings for a class in one place than scrolling up and down a Java file to look for annotations. With that said, using annotation does eliminate the use of an additional hbm file, which is good. 2. Although the mapping annotations are mostly standardized in Java Persistence API, there are still some Hibernate specific stuff that we often need to use, so the advantage of being portable (i.e replace Hibernate with another ORM library) by using annotations is somewhat limited. 3. I haven't had time to change mappings in CSNS to annotations yet. 4. Using annotations for mapping requires an additional lecture (or at least half of a lecture) to introduce the concept of annotation itself. I haven't found the place to add it to the class yet. |