遗留的Criteria API仍然被推荐? [英] Is legacy Criteria API still recommended?
问题描述
我的团队在Hibernate 3.x下一直使用hibernate Criteria API。最近,我们希望将Hibernate版本升级到5,但Criteria API似乎不再被推荐。但JPA看起来像一个完全不同的API,我们不想冒险。我们应该继续使用旧的Criteria吗?
My team has been using hibernate Criteria API for a long time under Hibernate 3.x. Recently, we want to upgrade Hibernate version to 5, but the Criteria API seemed not be recommended any more. But JPA looks like a totally different API which we don't want to risk. Should we keep using the old Criteria?
推荐答案
好吧,版本5.0标准章节相当不错:
Hibernate提供了一个旧的,遗留的org.hibernate.Criteria API,它应该被视为弃用。没有功能开发将针对这些API。最终,Hibernate特定的标准功能将作为JPA javax.persistence.criteria.CriteriaQuery的扩展移植。有关org.hibernate.Criteria API的详细信息,请参阅Legacy Hibernate Criteria Queries。
Hibernate offers an older, legacy org.hibernate.Criteria API which should be considered deprecated. No feature development will target those APIs. Eventually, Hibernate-specific criteria features will be ported as extensions to the JPA javax.persistence.criteria.CriteriaQuery. For details on the org.hibernate.Criteria API, see Legacy Hibernate Criteria Queries.
还有更多:
较早的Hibernate org.hibernate.Criteria查询API的用户将认识到一般的方法,尽管我们相信JPA API更加优秀,从该API中吸取的经验教训。
Users of the older Hibernate org.hibernate.Criteria query API will recognize the general approach, though we believe the JPA API to be superior as it represents a clean look at the lessons learned from that API.
所以,它看起来真的取决于您的团队。我花了一段时间才习惯JPA API,但现在已经非常顺利。为了获得非常大的读取性能,我放弃了Hibernate,但通常我没有任何使用JPA的问题。如果我需要更动态的东西,我倾向于使用 @NamedQueries
作为基本的acccess,而
So, it seems like it's really up to your team. It took me a while to get used to the JPA API, but it's pretty smooth sailing now. I have dropped back into Hibernate for performance for very large fetches, but in general I'm not having any problem using anything JPA. I tend to use @NamedQueries
for basic acccess, and the Criteria
API if I need something more dynamic.
编辑:更新我能解决性能问题,现在应用程序严格为JPA。
Update I was able to resolve the performance issue and the application is strictly JPA now.
这篇关于遗留的Criteria API仍然被推荐?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!