Get the App
SLTechnology News&Howtos  ›  Development  › 

Hibernate API analysis with examples

Shulou Source: shulou.com Published: 2022-06-02 08:00:19 11月28日 Update

This article introduces the relevant knowledge of "Hibernate API example Analysis". In the operation of actual cases, many people will encounter such a dilemma. Then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Java code

The interfaces in Hibernate API can be divided into: STRONG >

1. Provides interfaces for accessing database operations: Session,Transaction, and Query interfaces

two。 The interface used to configure Hibernate: Configruation.

3. Callback interface, using the application to accept events that occur within Hibernate, and make relevant responses: Interceptor,Lifecycle, and Validatable interfaces

4. The port used to extend the function of Hibernate: UserType,CompositeUserType

The core interface of Hibernate:

1.Configuration interface: configure Hibernate, start Hibernate, and create SessionFactory objects

2.SessionFactory interface: initializes Hibernate, acts as a proxy for data storage sources, and creates Session objects

3.Seission interface: responsible for saving, updating, deleting, loading and querying objects

4.Transaction: manage things; it is the data transaction interface of hibernate, encapsulating the transaction interface of the layer, and the underlying transaction interface: JDBC API,JTA,CORBA API

5.Query and Criteria interfaces: execute database query objects and control the query process

Callback APIs are divided into two types:

1.Lifecycle and Validatable interfaces: these two ports are implemented by persistence; the Lifecycle interface enables instances of persistent classes to respond to events that are loaded, saved, or deleted; and the Validatable interface enables instances of persistent classes to validate data before being saved

2.Interceptor interface: the Interceptor interface does not need to be implemented by persistent classes. Applications can define classes that specifically implement the Interceptor interface, and Interceptor implementation classes are responsible for loading, saving or deleting instances of persistent classes, and updating events.

Mapping type API of Hibernate: the Type API represents the Hibernate mapping type

The 1.PrimitiveType class maps the java base type

2.DateType: mapping java date types

3.BinaryType: mapping Byte [] type

This is the end of the content of "Hibernate API example Analysis". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Interface data type object event transaction instance query analysis content application database more knowledge program process application update configuration utility Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information NVidia MySQL Xiaomi Shulou Technology