Introduction to new features of Hibernate 5
In Hibernate 5, there are some new changes:
New boot API
Used to boot hibernate The classic way of (creating a sessionfactory) has always been to use the configuration configuration class. From the ancient version of hibernate to the present, it has always supported users to add new configurations and relationship mappings in any order, and allowed us to query and obtain the corresponding status and mapping information during the running process of the program. However, this also means that we can't be efficient according to some real-time configurations The mapping information can be easily established. This leads to many limitations and problems.
5.0 introduces a new boot API to alleviate these limitations and problems, while allowing us to better complete the integration work. For more information about the new boot API configuration guide, go to the user guide section of the hibernate official website
With certain restrictions, the configuration method can still be used, but some of its methods have been deleted. The configuration class still plays an important role in the bottom implementation of the new boot API
Spatial / GIS support
Hibernate spatial is a project that has existed for several years Karel maesen has made outstanding contributions to this
From hibernate 5 Since 0, hibernate spatial has been a part of Hibernate project to keep up with the mainstream of development. If your project needs to use GIS data, we highly recommend you to try hibernate spatial
Support Java 8
Although not fully supported, more accurately, hibernate 5 0 adds support for Java 8 date and time APIs to make it easier for us to complete the configuration attribute to database support of our entity mapping class This support isolates java8 dependencies by using a special tool hibernate - java8 For more information, see the basic types section in the hibernate official API domain model mapping guide
Extended auto ID generation support
Generationtype defined by JPA The auto attribute only supports numeric types Since 5.0, hibernate has been highly extended and supports a wider range of types, including built-in support of numeric types (such as integer \ long) and UUID Through the new extension class org hibernate. boot. model. Idgeneratorstrategyinterpreter, users can freely customize their own policies to use generationtype Auto properties
Naming policy separation
In order to support better interface design, the naming strategy is separated into two main parts:
1. org. hibernate. boot. model. naming. Implicitnamingstrategy: use this property when
The table or column we use does not explicitly specify a name to use
2. org. hibernate. boot. model. naming. Physicalnaming strategy: a table or column used to convert logical names (implicit or explicit) into a physical name
Attribute converter support
Hibernate 5.0 greatly improves the performance of JPA 2.0 1. Support for attribute converter:
1. Fully support the use of enumeration values of non @ enumerated annotations
2. Support for use with @ nationalized
3. It can be in HBM In the XML file, set type = "converter: fully. Qualified. Attributeconvertername" by using the following format
4. Integrate hibernate envers
5. Set values and map key values
6. Null values can now be processed effectively
7. Support conversion of parameterized types
Better "bulk ID table" support
The support for bulk ID table has been redesigned to better adapt to the support of different databases
transaction management
Transaction SPI also completed the main refactoring design as hibernate 5 Part of 0 update From the user's point of view, these are generally contacted only when it comes to the configuration part. Previously, the application will directly communicate with different back-end transaction strategies through org. Org hibernate. Transaction works effectively In 5.0, some support has been added, org hibernate. The API implementation of transaction will never change. On the back end, the org hibernate. Transaction impl will involve org hibernate. resource. transaction. Transaction coordinator, which represents the session given by the "transaction context" according to the back-end transaction policy. Users generally do not need to care about the difference.
Here we should pay attention to this change, which may affect our boot configuration In the previous application, we specified hibernate transaction. factory_ Class and points to org hibernate. engine. transaction. spi. TransactionFactory FQN. In Hibernate 5 0, the new agreement is org hibernate. resource. transaction. Transaction coordinator builder and specific use of hibernate transaction. coordinator_ class setting. For more details, see org. Org in JavaDocs hibernate. cfg. AvailableSettings. TRANSACTION_ COORDINATOR_ STRATEGY
The following short names are recognized as:
JDBC:: (default) indicates that JDBC based transactions are used (org.hibernate.resource.transaction.backend.jdbc.internal.jdbcresourcelocaltransactioncoordinatorimpl)
JTA:: says shows the use of JTA based transactions (org. Hibernate. Resource. Transaction. Backend. JTA. Internal. Jtatactioncoordinatorimpl)
Refer to the user manual for more details.
Pattern tool chain
hibernate5. 0 provides a lot of support for pattern tool chain (such as export \ verification \ import, etc.)
Session API classfication
A large number of Hibernate built-in APIs, such as (session, etc.), are all provincial-level into classes without complex type conversion
Improved OSGi support
This began with a dissatisfied vulnerability hibernate OSGi test The first part is a better test launch using Pax exam and karaf This will cause us to generate a hibernate karaf style file
OSGi support has improved a lot, thanks to the support from karaf and Pax developers and users
Improved bytecode enhancements
In Hibernate 5 A lot of work has been done on this in the 0 document, but there is still much room for improvement
summary
The above is an introduction to the new features of Hibernate 5 introduced by Xiaobian. I hope it will help you. If you have any questions, please leave me a message, and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!