Lazy versus eager fetching: what is the safe default?
Simple meaning
Lazy is the safe default for associations so you do not pull an entire object graph on every find.
Open the full page for Why, Steps, Example and Key takeaway.
Panel-ready Java Specialist questions for freshers and experienced developers. Practice at Coding Cadre in Faridabad, or Online from Delhi NCR.
Lazy is the safe default for associations so you do not pull an entire object graph on every find.
Open the full page for Why, Steps, Example and Key takeaway.
It is the first-level cache: a map of managed entities for the current unit of work, usually the transaction.
Open the full page for Why, Steps, Example and Key takeaway.
persist inserts a new entity and fails if the id already exists in some setups.
Open the full page for Why, Steps, Example and Key takeaway.
You pass PageRequest.of(page, size, sort) into a repository method that returns Page or Slice.
Open the full page for Why, Steps, Example and Key takeaway.
EntityManager is the JPA API for the persistence context.
Open the full page for Why, Steps, Example and Key takeaway.
It means persist, merge, remove, and refresh cascade to children.
Open the full page for Why, Steps, Example and Key takeaway.
INNER keeps only customers who have orders.
Open the full page for Why, Steps, Example and Key takeaway.
The engine walks a balanced tree of page pointers instead of reading every row.
Open the full page for Why, Steps, Example and Key takeaway.
Functions on the column, implicit type conversion, leading wildcards like LIKE '%foo', or low selectivity can force a sequential scan.
Open the full page for Why, Steps, Example and Key takeaway.
1NF: no repeating mark columns like mark1, mark2
Open the full page for Why, Steps, Example and Key takeaway.
Atomicity: all statements commit or none do.
Open the full page for Why, Steps, Example and Key takeaway.
Read uncommitted can see dirty data.
Open the full page for Why, Steps, Example and Key takeaway.
A covering index includes every column the query needs, so the engine never visits the heap or clustered table.
Open the full page for Why, Steps, Example and Key takeaway.
DISTINCT removes duplicate result rows.
Open the full page for Why, Steps, Example and Key takeaway.
It is a subquery that references columns from the outer query, so it may run once per outer row.
Open the full page for Why, Steps, Example and Key takeaway.
When a read path must join five tables on every product card and p99 latency is too high.
Open the full page for Why, Steps, Example and Key takeaway.
Synchronizing on this or on a public class object lets strangers lock the same monitor and deadlock you.
Open the full page for Why, Steps, Example and Key takeaway.
volatile makes reads and writes to that field visible across threads and prevents some instruction reordering around that field.
Open the full page for Why, Steps, Example and Key takeaway.
The consumer waits on the lock while the queue is empty, releasing the monitor.
Open the full page for Why, Steps, Example and Key takeaway.
synchronized is simpler and sufficient for most monitors.
Open the full page for Why, Steps, Example and Key takeaway.