Hibernate 5是否支持基于XML的实体映射? [英] Does Hibernate 5 support XML based entity mappings?
问题描述
您好,我的问题不是技术性的.我想知道休眠5是否支持基于XML的实体映射.
Hi my question is not technical. I want to know if hibernate 5 supports XML based entity mapping or not.
我的要求如下:
我想要一个在Jersey-Hibernate上的后端.我的前端是Android应用程序. 我想将我的实体POJO保留在一个公共项目中,以便它们将由应用程序和服务器共享. Gson将对序列进行序列化/反序列化. 但是由于android应用程序不支持所有Java库进行编译,因此我不希望我的common(POJO)依赖于某些库;在这种情况下,休眠注释.因此,我计划使用基于XML的配置.
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.
推荐答案
Hibernate 5同时支持旧版HBM
映射以及JPA XML映射.但是,HBM
映射不再是推荐的映射实体方法.如新用户指南中所示,所有示例利用注释.
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.
与HBM
映射相比,特定于Hibernate的注释提供的功能更多.在Hibernate 6中,计划将扩展机制添加到JPA XML映射中,因此不推荐使用HBM
映射.
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.
由于您要迁移到Hibernate 5,因此也最好从HBM
迁移到注释.
Since you are migrating to Hibernate 5, it's a good idea to migrate from HBM
to annotations too.
这篇关于Hibernate 5是否支持基于XML的实体映射?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!