Hibernate mapping configuration file (emphasis)
1 there is no fixed requirement for mapping profile name and location
2 in the mapping configuration file, label name property values realistic body class related content
(1 ) class Label name attribute value entity class full path
(2 ) ID tags and property Label name Property Value entity Class Property name
3 ID tags and property label, column property can be omitted.
(1 if the value and name are not written property values are the same
4 Property Label Type attribute, sets the types of table fields to be generated, and automatically corresponds to the type
Hibernate Core configuration file
1 Configure write location requirements
2 configuring three-part requirements
(1 ) The database part must be
(2 ) Hibernate part of the optional
(3 ) The mapping file must be
3 the core profile name and location are fixed
(1 ) Location: src below
(2) Name: Hibernate.cfg.xml
Hibernate core APIConfiguration
1 Code
(1) Under SRC, locate the name hibernate.cfg.xml configuration file, create the configuration object, and put the config file into this object (load core profile)
Sessionfactory (Key)
1 using Configuration Object Creation Sessionfactory Object
(1 ) Create Sessionfactory things to do in the process:
- according to the core configuration file, there is a database configuration, there is a mapping file part, into the database based on the mapping relationship to create the table
2 Create Sessionfactory Process , this process is particularly resource-intensive
(1 ) in Hibernate operation, it is recommended that a project generally create a sessionfactory Object
3 Specific Implementation
(1 Write the tool class, write the static code block implementation
* a static block of code executes when the class is loaded and executes only once
Session (emphasis)
1 session similar to JDBC in connection
2 Call the session to implement CRUD operations in different ways
(1) Add the Save method
(2) Modify the Update method
(3) Remove Delete method
(4) Query The Get method by ID
3 Session Object Single Thread object
(1) The Session object cannot be shared and can only be used by itself
Transaction
1 Transaction Object
2 transaction Commit and Rollback methods
3 Transaction Concepts (1 ) transaction Four features Atomicity, consistency, isolation, persistence Atomicity: Indivisible, either successful or successful all code executes, whereas one step fails and all operations do not Consistency: The total amount of data does not change before and after the Operation such as transfer more than a single person million, the other person will be less million Isolation: Multiple transactions operate on a record at the same time, they don't affect each other . Persistence: After the final transaction is committed real entry into the database, generating records ( data) |
Troubleshoot configuration files without prompting problems
1 Internet access available
2 introduce constraint files to eclipse in (1 ) Copy a word in the configuration file If you are not prompted, restart Development Tools |
----------------------------------
Welcome to reprint, please specify the original link: http://www.cnblogs.com/Joke-Jay/p/6522798.html
Detailed Hibernate configuration file