Spring Data Flashcards
What is Spring ORM and Spring Data?
-Spring ORM:Object Relational Mapper
Module designed to integrate data access code into a spring app
-Spring Data: project by SpringSource with the intent to unify and ease the access to different kinds of persistent storage for both SQL, and nonSQL databases
What is the Template design pattern and what is the JDBC template?
-Template design pattern is a pattern that encapsulates and supports similar algorithms to perform different kinds of business requirements by abstracting classes and allowing subclasses to determine concrete behavior.
-JDBCTemplate is a class that allows an object oriented way of executing queries to databases
What does @Transactional do? What is the PlatformTransactionManager?
-We put @Transactional over our DAO methods, indicates that the methods should execute in a transactional context.
-Central interface in Spring’s transaction infrastructure, apps can use directly but is not meant to be an API
What is a PersistenceContext?
It handles a set of entities which are stored in a persistent store such as a database. The context is aware of different states of an entity within the context and the store itself.
Explain how to integrate Spring and Hibernate using ContextualSession
-You can use JPA annotation in bean classes to map beans to tables
-Implement DAO classes
-Use SessionFactory in DAO implementations to perform transactions
-Use beans xml to integrate beans with spring
What interfaces are available in Spring Data JPA?
Repository
CrudRepository
PagingAndSortingRepository
JPARrepository
What is the difference between JPARepository and CrudRepository?
JPARepository extends PagingAndSortingRepository which extends CrudRepository and provides JPA related methods.
What is the naming conventions for methods in Spring Data repositories?
Follow Java naming conventions, an underscore _ can be used inside method name to manually define traversal points.
How are Spring repositories implemented by Spring at runtime?
Uses SpringData REST to create an implementation of the repository interface automatically
What is @Query used for?
Used to define SQL to execute, allows us to execute SQL queries in an object oriented manner.