DB Flashcards

1
Q

требования к Entity

A
  • @Entity
  • public or protected no-argument constructor
  • not final class methods fields
  • fields not public
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

жц Entity

A

There are mainly four states of the Hibernate Lifecycle :

Transient State
Persistent State
Detached State
Removed State

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

Cascade

A

CascadeType.ALL
PERSIST
MERGE
REMOVE
REFRESH
DETACH

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

ACID

A

Атомарность (Atomicity) - все операции транзакции должны быть выполнены или не выполнены вообще.

Согласованность (Consistency) - транзакция должна приводить базу данных в согласованное состояние.

Изолированность (Isolation) - каждая транзакция должна работать в изолированном режиме, т.е. изменения, внесенные одной транзакцией, не должны видны другим транзакциям до тех пор, пока первая транзакция не будет завершена.

Долговечность (Durability) - после успешного завершения транзакции изменения должны сохраняться в базе данных.

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

Transaction read phenomena

A

dirty
non repeatable
phantom

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

Isolation

A

Read Uncommitted
Read Committed - Postgres, Oracle
Repeatable Read - MySql
Serializable

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

как реализуются условия в SpringData repository

A
  • имя метода
  • @Query
  • Specification
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

transaction propagation

A
  • REQUIRED is the default
  • SUPPORTS, Spring first checks if an active transaction exists. If a transaction exists, then the existing transaction will be used. If there isn’t a transaction, it is executed non-transactional:
  • MANDATORY, if there is an active transaction, then it will be used. If there isn’t an active transaction, then Spring throws an exception
  • NEVER propagation, Spring throws an exception if there’s an active transaction:
  • NOT_SUPPORTED If a current transaction exists, first Spring suspends it, and then the business logic is executed without a transaction
  • REQUIRES_NEW, Spring suspends the current transaction if it exists, and then creates a new one
  • NESTED propagation, Spring checks if a transaction exists, and if so, it marks a save point. This means that if our business logic execution throws an exception, then the transaction rollbacks to this save point. If there’s no active transaction, it works like REQUIRED
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

n+1

A

The N+1 problem is the situation when, for a single request, for example, fetching Users, we make additional requests for each User to get their information.

Eager Fetch, JOIN FETCH

Creating separate methods, SQL and JPQL queries can help tailor them for each case.

hibernate assertSelectCount(1)

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

Join types

A

INNER JOIN, OUTER JOIN, CROSS JOIN, and SELF JOIN

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