Spring Data Flashcards

1
Q

What is JPA?

A

Java persistence API

  • a list of interfaces meant for the mapping/managing of relational data with java objects
  • describes which Java objects to persists and how to persist them
  • requires a specific implementation to be used, e.g. Hibernate
  • Spring Data JPA in practice: @Entity, @Table, @Id, @GeneratedValue, @Column
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Spring ORM and Spring Data?

A

Spring ORM = Spring Object Relational Mapping
- it is a framework built upon Hibernate, which is then built upon by Spring Data JPA

Spring Data = family of Spring modules dealing with data persistence
- includes modules such as Spring Data JPA, Spring Data MongoDB, and Spring Data Redis

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What interfaces are available in Spring Data JPA?

A
  • JpaRepository
  • extends PagingAndSortingRepository
  • extends CrudRepository
  • extends Repository
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is @Query used for?

A

Used to define custom behavior (i.e. SQL code) that may not be provided by Spring

@Query(“SELECT * FROM users SORT BY id ASC;”)
public List getUsersSorted();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Describe some naming conventions for Spring Data repository methods (think CRUD operations)

A

Operations

  • Retrieval: find
  • Creation/Update: save
  • Delete: delete

Queries

  • deal with collections: All
  • filter by criteria: By

Examples
- saveAll(), findByName(), deleteById()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly