Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the new features of Hibernate3

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

Xiaobian to share with you what new features Hibernate3, I believe most people do not know how, so share this article for everyone's reference, I hope you have a lot of harvest after reading this article, let's go to understand it together!

Hibernate3 New Features

Hibernate3 has greatly improved the application of the product, and has been improved based on Java 1.5, and integrated with EJB 3.0, which has greatly improved the function. Hibernate is also a great addition to Microsoft's other mainstream development platform. NET platform, so it has a stronger vitality.

The changes to Hibernate3's new features relative to Hibernate2 include three aspects:

(1) API changes The most significant change in API changes is the change in package names, mainly the change in the root path of the package. Programmers only need to look at the classes contained in Hibernate3.jar file in Eclipse to know: Hibernate 3's root path changes from net.sf.hibernate to org.hibernate. Because these two paths are completely different, programmers can use Hibernate2 and Hibernate 3 in the same application. If you want to upgrade an existing application to Hibernate3, Then the *** step of upgrading is to replace all net.sf.hibernate in Java source code with org.hibernate.

Also, in Hibernate3's new feature, HibernateException and all its subclasses inherit Java.lang.RuntimeException. Therefore, at compile time, the compiler no longer checks HibernateException. In Hibernate3, the CreateSQLQuery () method of the Session interface is deprecated and moved to the org.hibernate.classic.Session interface. Hibernate3 uses the new SQLQuery interface to accomplish the same functionality. New methods have also been added to both the UserType and CompositeUserType interfaces, which have been moved to the org.hibernate.usertype package, and the user-defined UserType and CompositeUserType implementation classes must implement these new methods. Hibernate3 provides the ParameterizedType interface for better reuse of user-defined types.

These major changes will affect the application, and programmers must make adjustments to make Hibernate3-based applications work properly.

(2) Metadata Metadata mainly refers to changes in the usage of various elements and attributes in Hibernate mapping files. The first is the document type definition of Hibernate mapping file, that is, the DTD file has changed, which programmers can find from the file header of any Hibernate3 mapping file, that is, the URL defined in the element has changed from http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd to http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd.

Another significant change is that the default value for the lazy attribute has changed from false to true, a decision Hibernate has made to optimize application performance. Because Hibernate prefetches all fields when lazy=false, programmers who wish to use lazy loading must manually set the lazy attribute to true in the mapping file. However, always prefetching results in significant resource consumption, which reduces application performance. So from an application perspective, it is preferable that the default value of lazy is true, so that the pre-fetch retrieval strategy is used only when necessary.

Hibernate3 uses the new ANTLR-based HQL/SQL query translator, although Hibernate2's query translator still exists. In Hibernate's configuration file, the hibernate.query.factory_class attribute is used to select the query translator.

That's all for Hibernate3, thanks for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report