Hibernate learning: CRUD Unit Test Cases + Knowledge Summary

Source: Internet
Author: User

One: Use Cases


Two: summary

Main interface:
1:annotationconfiguration
2:sessionfactory
3:session

Knowledge Points:
1:configure can specify the path to the hibernate file, if the Hibernate profile name is Hibernate.cfg.xml, then you do not have to write the file path
2:factory.opensession (); each time a call is made, a new session will be created
3:factory.getcurrentsession (); Gets the session from the context, if one is not created, creates a new session if not
4:factory.opensession (); manual close Required
Factory.getcurrentsession (); Close is not required, and when a transaction commits, it is automatically close
5:factory.getcurrentsession (); You need to include a way to get context in the Hibernate configuration file: Thread is the most common one, from the current thread to find
<property name= "Current_session_context_class" >thread</property>


6:session of three states
Transaction
Persistence
Detached

Difference:
There is no ID
Session has not closed
There are no values in the database

7: Two methods of querying
Load returns a proxy object that executes the SQL statement and delays loading when the object's properties are really being fetched.
Get executes and the SQL statement is immediately fetched. No delay


Hibernate learning: CRUD Unit Test Cases + Knowledge Summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.