Data, Security & Production
JPA and transactions, Spring Security and JWT, testing, caching, Kafka and resilience.
16 questions
Pick an answer to see instantly whether you're right, with an explanation. Questions are shuffled every attempt.
Question 1 of 16Score 0
You load 50 orders and then call order.getLines().size() on each. How many queries run with default lazy loading?
One query for the orders plus one per order — the N+1 problem. Fix with a fetch join, entity graph, batch fetching or a projection.
What is the default fetch type of @ManyToOne?
To-one associations are EAGER by default in JPA — set fetch = FetchType.LAZY explicitly.
A @Transactional method throws a checked IOException. By default the transaction…
Spring rolls back only on unchecked exceptions and errors unless you set rollbackFor.
Which propagation runs an audit write in an independent transaction that survives the caller’s rollback?
REQUIRES_NEW suspends the current transaction and uses a second connection.
What does a @Version field enable?
Updates include where version = ?; a concurrent change causes an optimistic locking failure you can map to 409.
Why disable spring.jpa.open-in-view in a REST API?
Fetch what you need inside transactional service methods instead.
Which ddl-auto setting is appropriate for production with Flyway?
Let migrations own the schema; validate checks entities against it.
In Spring Security, hasRole("ADMIN") checks for which authority?
Roles are authorities with the ROLE_ prefix, which hasRole adds for you.
When is disabling CSRF protection acceptable?
CSRF exploits automatically-sent cookies; bearer tokens in headers are not sent automatically by browsers.
A resource server validates JWTs signed with RS256. What does it need?
Asymmetric signatures are verified with public keys, usually discovered via issuer-uri.
Which test slice loads controllers but not services or repositories?
Mock the service layer with @MockitoBean.
What does @ServiceConnection on a Testcontainers bean do?
No more @DynamicPropertySource boilerplate for URLs, ports and credentials.
Kafka guarantees message ordering…
Use the entity id as the key so all its events land in the same partition.
What is the transactional outbox pattern for?
The event row is committed in the same transaction as the business data and relayed to the broker afterwards.
A circuit breaker is OPEN. What happens to new calls?
After the wait duration it moves to HALF_OPEN and lets a few trial calls through.
What does @Cacheable(sync = true) help with?
It coalesces concurrent misses for the same key within one instance; it does not lock across a cluster.
0%
Nice work
You scored 0 out of 16.