Hibernate learning: CRUD unit test cases + knowledge Summary

Source: Internet
Author: User

Hibernate learning: CRUD unit test cases + knowledge Summary

I. Use Cases


Ii. Summary

Main interfaces:
1: AnnotationConfiguration
2: SessionFactory
3: Session

Knowledge point:
1: configure can specify the path of the Hibernate file. If the Hibernate configuration file name is hibernate. cfg. xml, you do not need to write the file path.
2: factory. openSession (); each call creates a new session.
3: factory. getCurrentSession (); obtains the session from the context. If no session is created, a new session is created if no session is created.
4: factory. openSession (); close manually
Factory. getCurrentSession (); close is not required. When a transaction is committed, it is automatically closed.
5: factory. getCurrentSession (); you need to add the method to obtain the context in the Hibernate configuration file: thread is the most common method.
Thread


6. session Status
Transaction
Persistence
Detached

Differences:
Is there an id?
Is the session closed?
Is there a value in the database?

7: Two query methods
Load returns a proxy object. The SQL statement is executed only when the object attribute is obtained, delaying loading.
Get to get the SQL statement immediately. No Delay


Related Article

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.