Does Hibernate 5 support XML based entity mappings

2020-06-18 09:46发布

Hi my question is not technical. I want to know if hibernate 5 supports XML based entity mapping or not.

My requirement is like below :

I want a backend on Jersey-Hibernate. My front end is Android application. I want to keep my Entity POJOs in a common project such that they will be shared by both app and server. Gson will serialize/deserialize both side. But because android application doesn't support all java library in compilation, I don't want my common(POJO) depending on some library; In this case hibernate annotations. So I am planning to use XML based configuration.

2条回答
兄弟一词,经得起流年.
2楼-- · 2020-06-18 10:09

Hibernate 5 supports both the legacy HBM mappings as well as the JPA XML mappings too. However, HBM mappings are no longer the recommended approach to map entities. As illustrated in the new User Guide, all examples make use of annotations.

There are more features provided by Hibernate-specific annotations than it is the case with HBM mappings. In Hibernate 6, it is planned to add an extension mechanism to the JPA XML mappings, therefore HBM mappings are deprecated.

Since you are migrating to Hibernate 5, it's a good idea to migrate from HBM to annotations too.

查看更多
看我几分像从前
3楼-- · 2020-06-18 10:22

Yes, according to documentation (where authors recommended using annotations for mapping) is said that xml mapping is still possible: docs

So on - you can still us *.hbm.xml for entity mapping.

EDIT: ofc I mean *.hbm.xml

查看更多
登录 后发表回答