Home » Java » 4 Hibernate: use annotations (Annotation)

4 Hibernate: use annotations (Annotation)

introduces the Hibernate development steps in 2, Hibernate: introduction to :


(1) import the Hibernate library file and develop the drive file for the database used

(2) create the Hibernate configuration file: hibernate.cfg.xml

(3) creating a persistent class

(4) create object relational mapping file: *.hbm.xml

(5) add the object relational mapping file to the Hibernate configuration file

(6) write the code to access the database through Hibernate API


if annotations are used in the creation of a persistence class in step (3), steps (4) and (5) can be omitted. The following shows the full development steps for Hibernate development using annotations:


(1) using Maven to manage Hibernate dependencies, the POM file reads as follows

4.0.0
lesson
hibernate
0.0.1-SNAPSHOT


junit
junit
4.12


org.hibernate
hibernate-core
5.2.10.Final


mysql
mysql-connector-java
5.1.40



(2) create the Hibernate configuration file: hibernate.cfg.xml

specific steps can be found in 2, Hibernate,

: introduction, , here is the configuration file

(3)

Latest