Scrivio Interview library
ConceptFoundations8 min read · updated 12 November 2026

You are a senior developer and your team decided to use Spring Data JPA with Flyway instead of MyBatis for a new service. Write down what an architecture decision record for this decision should contain.

An architecture decision record for this choice should have a title, a status such as proposed, accepted or superseded, and a date. It then explains the context (the problem and the forces behind it), states the decision plainly, compares the options that were considered with their main pros and cons, and lists the consequences, good and bad. It should fit on one or two pages and live in the repository, for example in docs/adr, so it is reviewed like code.

Why this question is asked

Choosing a persistence approach is one of those decisions that shapes a service for years. Two years from now, someone will open the repository, see Spring Data JPA and Flyway, and wonder why the team did not use MyBatis, which they know from another project. Without a written record, the only answer is whoever still remembers. Interviewers ask this question to see whether we can capture a decision so that a future reader understands it, not just whether we know the template. In this answer, we will recap what an ADR is, go through each part of the record for this exact decision, see a complete example file, and look at where to keep it and how long it should be.

1A Quick Recap of Architecture Decision Records

An architecture decision record, usually shortened to ADR, is a short document that captures one significant technical decision: what we decided, why, and what we gave up. The idea became popular through a blog post by Michael Nygard, and the shape he proposed is still the one most teams use. Each record covers exactly one decision, so the records stay small and easy to link to.

Notice the word significant. Picking a variable name is not an ADR. Choosing how a service talks to its database is, because it affects every query we write, how we test, how we evolve the schema, and which skills new team members need. A good rule of thumb is that a decision deserves an ADR when it would be expensive to reverse or when people outside the team will be affected by it.

Before we write ours, let us recall the three technologies. Spring Data JPA is a Spring library that sits on top of JPA, the Jakarta Persistence API, with Hibernate usually doing the real work: we write entity classes and repository interfaces, and most simple queries are generated for us. MyBatis takes the opposite approach: we write the SQL ourselves, in XML or annotations, and MyBatis maps the result rows onto objects. Flyway is a migration tool: it applies versioned SQL scripts such as V1__create_orders.sql to the database in order and records which ones have already run.

2Title, Status and Date

The record starts with a number and a short title that names the decision, not the topic. 'ADR 0007: Use Spring Data JPA and Flyway for persistence in the order service' is better than 'Persistence', because a reader scanning the list of ADRs can see the decision without opening the file.

Next comes the status. A record usually starts as proposed while the team discusses it, becomes accepted once agreed, and may later become superseded when a newer ADR replaces it, with a link to that newer record. Some teams also use deprecated or rejected. The date matters more than it seems: a decision made in 2026 with the team we had then is judged against the facts of 2026. When someone reads it in 2029, the date tells them how old those facts are.

3Context: the Problem and the Forces

The context section is the most valuable part, and the one people most often skip. It describes the situation that made a decision necessary and the forces pulling in different directions. For our service, the forces are concrete. The team of six has strong JPA and Hibernate experience and only one person has used MyBatis. Most of the service is ordinary create, read, update and delete work on about 15 tables, with three or four reporting queries that need hand-written SQL. The schema will change often in the first year, so we need repeatable, versioned migrations that run the same way in tests, staging and production.

The reason we write these forces down is that they are what a future reader needs to check. If the team later grows into a group of SQL specialists, or the service turns into mostly complex reports, the context has changed, and the decision deserves another look. A decision without its context can only be obeyed or ignored, never re-evaluated.

4Options Considered and the Decision

We then list the real options and their main pros and cons. Two or three options are normal; listing seven usually means the team has not done the thinking yet. It is also honest to record the option we did not pick in its best light, because that is the option a future reader will be tempted by.

The decision itself is stated plainly, in one or two sentences, in the active voice: 'We will use Spring Data JPA with Hibernate for data access, and Flyway for all schema changes. Complex reporting queries will use native queries or JdbcClient.' No hedging, and no 'we might'. Anyone should be able to tell from this sentence what is allowed in the codebase.

Options for the order service's persistence
OptionMain advantagesMain drawbacks
Spring Data JPA + Flywayteam knows it; little code for CRUD; Spring Boot supporthidden SQL; N+1 and lazy-loading traps
MyBatis + Flywayfull control of SQL; easy to tune queriesmore code per table; only one person knows it
JdbcClient + Flywaysimple, no ORM magicmanual mapping for 15 tables; slow to build
The options table belongs in the record, so readers see what was rejected and why.

Notice that the decision mentions the escape hatch for complex queries. That anticipates the strongest argument for MyBatis and answers it inside the decision, so nobody has to rediscover it.

5Consequences: What Gets Easier and What Gets Harder

Every decision has a price, and the consequences section is where we admit it. Good consequences for our choice: simple repositories need almost no code, Spring Boot wires Flyway to run migrations at startup, and new developers are productive quickly. Bad consequences: the SQL Hibernate generates is hidden, so we must watch for the N+1 problem (one query for a list, then one more query per item) and lazy-loading errors, and we will need SQL logging in tests. Follow-up work belongs here too: add a test that fails on N+1 queries, write a short guide for when to use native queries, and agree that Flyway scripts are never edited after they are merged.

The full record is short. Here is what the file looks like in the repository.

Java
# ADR 0007: Use Spring Data JPA and Flyway for persistence in the order service
Status: Accepted (2026-03-12)
Deciders: order team (6 engineers), reviewed by platform architect
## Context
Mostly CRUD on ~15 tables, 3-4 reporting queries. Team strong in JPA,
one person knows MyBatis. Schema will change often in year one.
## Options
1. Spring Data JPA + Flyway
2. MyBatis + Flyway
3. JdbcClient + Flyway
(pros and cons per option)
## Decision
Spring Data JPA (Hibernate) for data access; Flyway for every schema change.
Reporting queries use native queries or JdbcClient.
## Consequences
+ little code for CRUD, fast onboarding
- generated SQL is hidden: enable SQL logging in tests, check for N+1
Follow-up: N+1 test, native query guideline, never edit merged migrations

Notice that the file is plain Markdown, numbered, and dated. Inside the file Markdown lists are fine; it is a working document for the team, and brevity is the point.

6Keeping It Short and Next to the Code

Where the record lives decides whether anyone reads it. The common choice is a folder such as docs/adr in the same repository as the service. The reason is simple: the ADR then goes through a pull request like any code change, reviewers comment on it line by line, and its history is in git next to the code it explains. A wiki page drifts away from the code within months, and nobody reviews it.

Length matters for the same reason. One or two pages is plenty. If writing an ADR takes a day, people stop writing them. If it takes thirty minutes, they become a habit. When a later decision changes this one, for example a move to MyBatis for a reporting service, we do not edit the old record; we write a new ADR and mark the old one superseded, with links both ways, so the history stays readable.

7Follow-up questions

Should every small technical choice get an ADR?

No. If every library upgrade needs a record, people treat ADRs as paperwork and stop writing the important ones. Write one when a decision is hard to reverse, affects other teams, or will make a future reader ask why. Choosing the persistence approach qualifies; choosing a JSON library inside one module usually does not.

Why not just put this in a Confluence page or a design doc?

A design doc often describes a whole system and keeps changing, so it is hard to tell what was decided when. An ADR records one decision at one moment and is never rewritten, only superseded. Keeping it in the repository means it is reviewed in a pull request, versioned with the code, and found by anyone who clones the service.

What if the team later regrets the decision?

Then the ADR is doing its job. We read its context, see which forces have changed, and write a new ADR that proposes the change and explains why. The old one is marked superseded. Regret is information, and the record makes it possible to discuss it calmly instead of arguing about who chose what.

8Conclusion

In this answer, we saw that an ADR for choosing Spring Data JPA and Flyway over MyBatis has a clear title, a status and a date, a context section that names the real forces such as team skills, query complexity and migration needs, the options with their pros and cons, a plain decision, and honest consequences with follow-up work. We also saw why it should be short and stored in the repository, where it is reviewed like code and superseded rather than edited.

What to say in the interviewAbout 90 seconds aloud

Open with

I would write it as a short Markdown file in docs/adr, numbered, something like ADR 0007: use Spring Data JPA and Flyway for persistence. At the top I put the status, proposed while we discuss it and accepted once we agree, with the date, because the date tells a future reader how old the facts are.

Then, if they want more

Then the context, which I think is the most important part: the team knows JPA well and only one person knows MyBatis, the service is mostly CRUD on about fifteen tables with a few reporting queries, and the schema will change a lot in the first year so we need versioned migrations.

Then the options, usually JPA, MyBatis and maybe plain JdbcClient, each with its main pros and cons, and I try to write the rejected option fairly. Then the decision in one plain sentence, including the escape hatch, for example that reporting queries use native SQL or JdbcClient.

Finally the consequences: CRUD becomes cheap and onboarding is fast, but the SQL is hidden, so we need SQL logging in tests and a check for N+1 queries, and we agree never to edit a merged migration. I keep it to a page or two and put it in the repo so it goes through a pull request like code.

If we change our minds later, we write a new ADR and mark this one superseded rather than editing it.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "You are a senior developer and your team decided to use Spring Data JPA with Flyway...": https://scrivio-interview-library.netlify.app/architecture/architecture-decisions/7aa51b3849/