The choice between using annotations, XML, or a combination of both in professional projects varies depending on the specific project and the preferences of the development team. There is no one-size-fits-all answer.
In recent years, the trend in the Hibernate community has shifted towards using annotations as the preferred approach for configuration. Annotations provide a more streamlined and concise way of configuring Hibernate, and they are directly integrated with the entity classes, making the code more cohesive and easier to read.
However, there are still cases where XML configuration is preferred. Some teams may have established conventions or practices in place that favor XML configuration. Additionally, XML configuration can be useful for scenarios that require advanced customization and fine-grained control over mapping, such as legacy databases or complex mapping relationships.
In some cases, a hybrid approach is adopted, where annotations are primarily used for most entities, but XML configuration is used for specific entities or for certain advanced mapping scenarios.
Ultimately, the choice between annotations, XML, or a combination of both depends on factors such as project requirements, team preferences, codebase consistency, and specific mapping complexities.