I’ve been using Hibernate for a few years but have only used it with annotations, and by setting the connection parameters in my code.
Am I ‘missing something’ by not using the XML files? Are there important capabilities available only in XML? Are there situations or patterns where it makes sense to use the XML?
I think it’s pretty safe to say that you’re not missing out on anything.
If there are any capabilities in XML that can’t be represented in attributes (and I believe there are some rare cases) then you still have the option to use [RawXml] and write the XML in the attribute. So you can’t possibly miss out on any functionality.
It might make sense to use XML if you have enough programmers in your team who simply prefer to manage separate files or if there is a genuine need to edit xml mappings on the fly. Xml mapping files are probably easier to manipulate for very complex mapping and they can contain useful information (comments on fetching strategies etc).
There is also the issue of architecture, where some people argue that separating the mapping into XML files provides a better separation between business-related code and instructions on how it is persisted.