@GeneratedValue Strategies — Concept Check
Questions on @GeneratedValue Strategies. AUTO delegates to the provider; IDENTITY uses DB auto-increment; SEQUENCE uses a DB sequence (most efficient for batch inserts); TABLE uses a dedicated ID table (avoid in production).
Questions in this quiz
7 questions on @GeneratedValue Strategies — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.A developer is using the IDENTITY strategy for primary key generation in a MySQL database. They notice that batch inserts are not performing well. What is the likely cause?
- AMySQL does not support IDENTITY strategy
- BBatch size is set too high
- CIDENTITY prevents JDBC batch inserts due to immediate ID retrieval
- DDatabase connection is slow
2.In a PostgreSQL database, which @GeneratedValue strategy is most efficient for batch inserts?
- ASEQUENCE with a configured allocation size
- BIDENTITY with default settings
- CAUTO with provider default
- DTABLE with default settings
3.A team is using the TABLE strategy for ID generation in a production environment. They experience performance issues. What is the likely reason?
- AIncorrect allocation size
- BTABLE strategy is not supported in production
- CTABLE strategy is slow and lock-prone
- DDatabase is not optimized
4.A developer wants to use the SEQUENCE strategy in MySQL for bulk inserts. What should they consider?
- ASEQUENCE strategy is not supported in MySQL
- BIDENTITY is better for bulk inserts in MySQL
- CMySQL needs a sequence emulation table
- DSEQUENCE is natively supported in MySQL
5.Which strategy should be avoided in production due to its slow performance and locking issues?
- ATABLE
- BSEQUENCE
- CAUTO
- DIDENTITY
6.A developer uses SEQUENCE with an allocationSize of 50 and notices improved batch insert performance. Why does this happen?
- AIDENTITY strategy is enabled
- BAUTO strategy is used by default
- CTABLE strategy is more efficient
- DSEQUENCE pre-fetches IDs, reducing DB round-trips
7.When using IDENTITY strategy, why might a developer experience poor performance with batch inserts?
- AIDENTITY is not supported in MySQL
- BIDENTITY requires immediate key retrieval, disabling batching
- CDatabase is misconfigured
- DBatch size is too small