Interview Refresher for SpringData JPA & Hibernate Concepts

所在平台: Udemy

课程主页: https://www.udemy.com/course/get-interview-ready-with-springdata-jpa-hibernate-concepts/

课程评论:没有评论

第一个写评论        关注课程

课程简介

课程名称:Spring Data JPA与Hibernate概念面试复习 课程概述:本课程旨在帮助学员学习Hibernate和Spring Data JPA的所有概念,以备战面试。学员将深入了解以下内容: 1. **Hibernate ORM框架 - JPA实现**:了解Hibernate的分层架构,使用户能够在不需了解底层API的情况下进行操作,提供持久性服务和持久对象。 2. **Hibernate应用架构及核心类**: - **Configuration对象**:Hibernate应用中的第一个对象,通常在应用初始化时创建。提供数据库连接配置和类映射设置,并用于创建SessionFactory对象。 - **SessionFactory对象**:线程安全,供应用中的所有线程使用,通常每个数据库需要一个SessionFactory。 - **Session对象**:轻量级,每次与数据库交互时实例化,负责保存和检索持久对象。 - **Transaction对象**:表示数据库的一次工作单元,支持事务功能。 - **Query对象**:使用SQL或Hibernate查询语言(HQL)字符串从数据库检索数据。 - **Criteria对象**:用于创建和执行面向对象的条件查询。 3. **Hibernate对象状态**: - transient(瞬态):未关联到Session的持久化类实例,没有数据库表示和标识符值。 - persistent(持久):已与Session关联,有数据库表示和标识符值。 - detached(游离):成功关闭Hibernate Session后,持久实例不再关联于Session。 4. **Hibernate缓存机制**:提升系统性能的机制,缓存最近使用的数据。包括: - **一级缓存**:Session缓存,所有请求必须通过此缓存。 - **二级缓存**:可选缓存,按类和集合配置,负责跨Session的对象缓存。 - **查询级缓存**:缓存查询结果集的机制,集成二级缓存。 5. **JPA的主键值生成策略**:提供四种方式,包括自动选择、身份、序列和表。 6. **Spring Data JPA**:建立在Hibernate之上的抽象层,简化JPA基础的仓库实现,减少了实现数据访问层所需的样板代码,使开发者可以专注于定义接口,Spring将自动提供实现。 本课程将通过上述内容,为求职者在面试中准备Spring Data JPA和Hibernate相关的知识,提高成功机会。

课程评论(0条)

课程详情

In this course, you will learn all the concepts of Hibernate and Spring Data JPA to get ready for an Interview.You will learn about the following:Hibernate ORM Framework - JPA ImplementationHibernate has a layered architecture that helps the user to operate without having to know the underlying APIs. Hibernate makes use of the database and configuration data to provide persistence services (and persistent objects) to the application.Hibernate Application Architecture with its important core classes.Configuration ObjectThe Configuration object is the first Hibernate object you create in any Hibernate application. It is usually created only once during application initialization.The Configuration object provides two keys components −Database Connection configurationClass Mapping SetupSessionFactory ObjectConfiguration object is used to create a SessionFactory object.The SessionFactory is a thread safe object and used by all the threads of an application.We would need one SessionFactory object per database using a separate configuration.Session ObjectA Session is used to get a physical connection with a database. The Session object is lightweight and designed to be instantiated each time an interaction is needed with the database. Persistent objects are saved and retrieved through a Session object.Transaction ObjectA Transaction represents a unit of work with the database and most of the RDBMS supports transaction functionality. Transactions in Hibernate are handled by an underlying transaction manager and transaction (from JDBC or JTA-Java Transaction API).Query ObjectQuery objects use SQL or Hibernate Query Language (HQL) string to retrieve data from the database and create objects. A Query instance is used to bind query parameters, limit the number of results returned by the query, and finally to execute the query.Criteria Object(Filtered Select query with many Where condition)Criteria objects are used to create and execute object oriented criteria queries to retrieve objects.HIBERNATE OBJECT STATESA new instance of a persistent class which is not associated with a Session, has no representation in the database and no identifier value is considered transient by Hibernate:// person is in a transient stateA persistent instance has a representation in the database, an identifier value and is associated with a Session. You can make a transient instance persistent by associating it with a Session:Now, if we close the Hibernate Session, the persistent instance will become a detached instance: it isn't attached to a Session anymore (but can still be modified and reattached to a new Session later though).HIBERNATE CACHINGCaching is a mechanism to enhance the performance of a system. It is a buffer memory that lies between the application and the database. Cache memory stores recently used data items in order to reduce the number of database hits as much as possible.Caching is important to Hibernate as well. It utilizes a multilevel caching scheme as explained below −First-level CacheThe first-level cache is the Session cache and is a mandatory cache through which all requests must pass. The Session object keeps an object under its own power before committing it to the database.Second-level CacheSecond level cache is an optional cache and first-level cache will always be consulted before any attempt is made to locate an object in the second-level cache. The second level cache can be configured on a per-class and per-collection basis and mainly responsible for caching objects across sessions.Query-level CacheHibernate also implements a cache for query resultsets that integrates closely with the second-level cache.This is an optional feature and requires two additional physical cache regions that hold the cached query results and the timestamps when a table was last updated. This is only useful for queries that are run frequently with the same parameters.JPA offers 4 different ways to generate primary key values: @IdAUTO: Hibernate selects the generation strategy based on the used dialect,IDENTITY: Hibernate relies on an auto-incremented database column to generate the primary key,SEQUENCE: Hibernate requests the primary key value from a database sequence,TABLE: Hibernate uses a database table to simulate a sequence.SPRING DATA JPA - Abstraction layer built on top of HibernateSpring Data JPA, part of the larger Spring Data family, makes it easy to easily implement JPA based repositories. This module deals with enhanced support for JPA based data access layers. It makes it easier to build Spring-powered applications that use data access technologies.Implementing a data access layer of an application has been cumbersome for quite a while. Too much boilerplate code has to be written to execute simple queries as well as perform pagination, and auditing. Spring Data JPA aims to significantly improve the implementation of data access layers by reducing the effort to the amount that's actually needed. As a developer you write your repository interfaces, including custom finder methods, and Spring will provide the implementation automatically.

课程标签

0人关注该课程

主题相关的课程