Why are people continuing to use xml mapping files instead of annotations?

Viewed 7287

I've observed the strange fact (based on the questions in the hibernate tag) that people are still actively using xml files instead of annotations to specify their ORM (Hibernate/JPA) mappings.

There are a few cases, where this is necessary:

  • you are using classes that are provided, and you want to map them.
  • you are writing an API, whose domain classes can be used without a JPA provider, so you don't want to force a JPA/Hibernate dependency.

But these are not common cases, I think.

My assumptions are:

  • people are used to xml files and don't feel comfortable / don't want to bother learning to use the annotation approach.
  • Java pre-1.5 is forced upon the project and there is nothing to do about it
  • people don't know that annotations are a full-featured replacement of xml mapping.
  • legacy systems are supported and hence changing the approach is considered risky
  • people fear that mixing annotations (meta-information) with their classes is wrong.

Any other possible explanations?

12 Answers
Related