Data persistence (JDBCEJBJDOOJBHibernate)

xiaoxiao2021-03-06  101

1. Problem Domain 1) Persistent data can be accessed and must also be a persistent persistent data storage that is even if the data store that still exists even in the case of server crashing 2) Map (ORM) persistent data for the problem domain object relationship (DA) 3 ) Pregnant point data integrity concurrent connection management data synchronization 2. Are you still writing SQL access database? Are you still Write SQL? Still use JDBC SQL (DAO)? Of course, this is the most original, most direct way to visit the lasting data layer, high running efficiency, but the DAO object and SQL language are closely coupled to maintenance. 3. J2EE's data solution? EJB BMP & CMP (Entity Bean / Session Bean /) Entity Bean: The response time of the resource / concurrent request is slow SESSION bean :? 4. JDOJDO is a Java Database Object, an object-oriented persistent mechanism, a lightweight framework. Personal PO and POJO PERSISTENT OBJECT, Entity Pojo Plain in the corresponding database, unformatted normal Java object, load and storage lasting data 5 JDO Ormjdo implementation: 1) Write POJO2) Compile POJO3) ORM uses Enhancer, Handle the Class file of Pojo, replace POJO with the same name PO, the PO byte code generated by the ENHANCER generated by the object and the relationship map different JDO products may vary, may affect the portability between JDO products 4) Running the PO JSP is also running in the compile period to run, actually running a servlet in the running period, not JSP 6 JDO ProblemsPo, cannot be separated from PM (Hibernate Session) VO static Pohancer's Enhancer's Enhancer Cannot run period dynamic Defects of ENHANCE JDO Product Split 7. OJBOBJECT RELATIONAL BRIDGE (OJB) An Orm Tool Allows Transparent Persistence for Java Objects Against Relational Databases. Db.apache.org/ojb/ Document is too simple, too small OJB Next version full support JDO

8. Hibernate ORMHIBERNATE: 1. Write Pojo2, compile POJO3, run directly, in the runtime, translated POJO to PO by Hibernate's CGLIB dynamics.

9. What 's A Best ORM SHOULD BE? ORM lightweight package, avoid introducing too much complex issues, easy to debug, and also reduce the burden of programmers. With scalability, API open products have a stable development guarantee. Open source, functional customization. Othertoplink, CoCobase, Castor Apache Ojb9. HibernateJava Objects Lightweight Lightweight Package Frames Persistent Layer Design Experience Summary ORM Mapping Tool provides data query and recovery mechanisms from Java class to data tables. Greatly reduce the workload of the operational database relative to the use of JDBC and SQL to manually operate the database and a variety of web servers or application servers to support almost all popular database servers (up to 16), so that dynamic queryApplication can be used in Java Replacing most JDBC code in the application

10. Solution? Read / write require multi-table mapping transaction support development cycle resource cost application

11. EJB Architecture Compare: Traditional Architecture: Entity Beansession Bean <-> Entity Bean <-> DBJDBC In order to resolve performance barriers to alternative architectures: session bean <-> DAO <> JDBC <> DBHibernate improves the development efficiency of the above architecture : Session bean <-> DAO <> Hibernate <-> DB comparison memory consumption / running efficiency / development efficiency / distributed / security check, cluster, load balancing support can be integrated into the J2EE system as a persistent layer frame 1) memory Consumption: Architecture 2 using JDBC is undoubtedly the first three-time EJB architecture 1 worse. 2) The code of the operational efficiency JDBC is very optimized. The JDBC architecture runs the highest efficiency requires the programmer very well. JDBC, use the BATCH statement, adjust the parameters such as PreApredStatement, and the results set Cache, etc. Under normal circumstances, the programmer does not do this Hibernate / JDBC / EJB3) Development Efficiency: With JBuilder's support and simple items, the EJB architecture has the highest efficiency, JDBC, Hibernate is the worst. Large projects, especially the persistent layer, and the Hibernate is highly efficient, and the EJB architecture is likely to fail. 4) Support for distributed / security checks, clusters, and load balancing 12. Implements hibernate1) Configuring HibernateHibernate Developer Hibernate Profile Hibernate.cfg.xmlConnection.driver_class etc 3) Creating a Data Model 3) Creating a Persistent Object 4) Writing Object and Data Table Mapping Description 5) Object - Relationship Mapping XML file 6) , Write and business logic persistence: Hibernate API13. Test, release benefits: PerformanceLightWeight dynamic query inheritance and polymorphism

14. Resource: www.hibernate.orgwww.hibernate.org.cn: 8000 (Hibernate Chinese Www.sourceforge.neetwww.huihu.org/com

转载请注明原文地址:https://www.9cbs.com/read-97413.html

New Post(0)