1. Object-oriented design of the internal operation of the software can be understood to be in the continuous creation of new objects, establish the relationship between objects, call the method of the object to change the state of each object and the process of object extinction, regardless of the process and operation of the program, Essentially to get a result, the difference in the running results of a moment in the program and the next is a change in the state of the object in memory.
2.In order to maintain the running state of the program in the case of shutdown and insufficient memory space, it is necessary to save the state of the object in memory to the persistence device and restore the state of the object from the persistence device, usually saving the large amount of object information to the relational database. FromJavarunning function of the program, the ability to save the state of the object, compared to other functions of the system, should be a very humble subordinate function,JavaAdoptJDBCto implement this function, the humble function is to write a lot of code, and the only thing to do is to save objects and restore objects, and those massiveJDBCThe code has no technical content and is basically written in a routine set of standard code templates, which is a hard work and repetitive work.
3.Save with DatabaseJavaThe object and the object to be recovered when the program is run are actually implementedJavathe mapping between an object and a relational database record, calledORM(i.e.Object Relation Mapping), people can encapsulateJDBCcode to implement this function, the encapsulated product is calledORMFramework,Hibernateis one of the popularORMFramework. UseHibernateframe, without writingJDBCcode, just call aSavemethod, you can save the object to a relational database simply by invoking aGetmethod, you can load an object from the database.
4.UseHibernateThe basic process is: ConfigureConfigurationobjects, generatingsessionfactory, creatingSessionobject, starting the transaction, completingCRUDoperations, committing transactions, closingSession.
5.UseHibernate, you first configureHibernate.cfg.xmlConfiguration database connection information and dialects, and configure the appropriate for each entityHbm.xmlfiles,Hibernate.cfg.xmlin the file, you need to register eachHbm.xmlfile.
6. hibernate session caching principle, cascading, deferred loading, and hql query.