Quickly understand hibernate configuration files and mapping files

Hibernate is a thorough ORM (object relational mapping) open source framework.

Let's take a look at the high-level view of Hibernate architecture given in the official document:

Where Po = POJO + mapping file

According to the architecture view, we can know that the whole project implemented by hibernate framework includes the whole important configuration file:

Hibernate configuration file: realize hibernate basic configuration, which is the basis for hibernate to interact with DB friendly; During development, it is placed in the SRC directory and named hibernate cfg. XML (hibernate. Properties) hibernate mapping file: realize the mapping configuration between POJO and DB tables; For maintenance convenience, it is generally placed in the same directory as the corresponding POJO and named pojoname hbm. xml。 Although the mapping relationship between multiple POJOs and database tables can be configured in one mapping file, it is recommended that only one POJO and database table be configured in one mapping file.

1、 Hibernate configuration file details

Hibernate configuration files come in two forms: XML and properties

I personally recommend using XML, because the associated mapping file cannot be configured in properties, which will bring some unnecessary coding in subsequent implementation;

XML (hibernate. CFG. XML) file details:

Properties (hibernate. Properties) file details

2、 Mapping file details

Due to space, the most basic configuration is described in detail here

summary

The above is all about quickly understanding hibernate configuration files and mapping files. I hope it will be helpful to you. Interested friends can refer to: Hibernate implementation of pessimistic lock and optimistic lock code introduction, hibernate core idea and interface introduction, detailed explanation of the use method of Java atomicinteger class, etc. if you have any questions, you can leave a message at any time, and the editor will reply to you in time. Welcome to exchange and discuss.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>