The question is, what is your taste - both ways can (basically) coincide, the difference is how to write.
With annotations, you have the Java member variable / receiver and the mapping directly in one place.
Xml mapping files provide a better overview of the table and its mapping.
In my opinion, xml mapping files help improve the design of the database and application. Annotations, as a rule, force the direction of the Java table class → mapping → database, which is the wrong direction (the database should always be designed first - changing database tables in the future is a lot of effort - most of the performance leaks are in poor database design - Java -classes can easily be changed at any time).
If there is one functional advantage of xml files: if you have different databases with structural differences, for example, one Oracle database and one MySQL database, maybe some differences in table names and data types, then to transfer your application from one database to another only needs to write a few new mapping files. You do not need to change one line of Java code. This is not possible with annotations.
I prefer to use xml mapping files. This is my taste.
source share