Skip to main content
ProductsDesktop toolsTASTECADDrawing reviewTASTEFILESFile managementTASTEFTPFile transferTASTESSHRemote workspaceTASTEZIPCompression and extractionTASTEWINMFile managementDeveloper toolsTASTECODERust integrated development environmentTASTESTUDIOIntegrated development and test environmentTASTEETLData integration (ETL)ServersTASTEREMOTERemote desktop serverTASTEGEOGeospatial serverTASTEMAILMail workspaceInvestingTASTESTOCKStock auto-trading desktop appGet startedDownloadsDocumentationBuyAll products
Marketplace
News
TechNewsToday's dev newsDeveloper docsProgramming languagesRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWeb front-end frameworksNext.jsReactVue.js · NuxtSvelteKitAngularServer frameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressApp & desktop frameworksTauriFlutterReact NativeElectronAlgorithmsAlgorithm basicsCore algorithmsAdvanced algorithmsPractical algorithms
CommunityProjectsDevelopment logsPromptsAI tool issuesShowcaseCommunity guide
Work with usTech transferWebsite buildDesktop app buildRelease and payment pipelineSales partnerContact
ServicesRemote desktopCustom installer packages
TASTEDEV
Products

Desktop tools

TASTECADComplex drawings, opened with easeTASTEFILESJust the files you need, as fast as possibleTASTEFTPThe tidiest path for your filesTASTESSHA stronger link between you and your serversTASTEZIPPack faster, unpack saferTASTEWINMA keyboard-first file manager with two panes

Developer tools

TASTECODEEdit, build, debug and test Rust apps in one windowTASTESTUDIOFrom editing to remote tests and approved AI fixesTASTEETLMove data while you watch the values

Servers

TASTEREMOTEA remote desktop you run on your own serverTASTEGEORebuilding a GeoServer-compatible geospatial server in RustTASTEMAILTake back control of your email

Investing

TASTESTOCKStock auto-trading that follows the rules you set: when, and what

Get started

DownloadsLatest builds of every productDocsHow to use each productBuySubscriptions and perpetual licencesAll productsEvery product at a glance
All products
MarketplaceNews
Tech

News

Today's dev newsOfficial announcements on languages, frameworks, GitHub and AIDeveloper docsGuides to languages, frameworks and algorithms

Programming languages

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Frameworks

Web front-end frameworksNext.jsReactVue.js · NuxtSvelteKitAngular
Server frameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
App & desktop frameworksTauriFlutterReact NativeElectron

Algorithms

Algorithm basicsComplexity analysis · Sorting · Searching · Basic data structures · Trees and heapsCore algorithmsGraph traversal · Shortest paths & minimum spanning trees · Dynamic programming · Greedy algorithms · Divide and conquer · BacktrackingAdvanced algorithmsString algorithms · Math and number theory · Bit manipulation · Segment trees · Union-findPractical algorithmsCoding interview strategy · LRU cache · Rate limiting · Consistent hashing
All development docs
Community
ProjectsDiscover builders and their workDevelopment logsDecisions and lessons learnedPromptsReusable instructionsAI tool issuesProblems and workarounds for Claude, Codex, GeminiShowcaseFinished resultsCommunity guideHow we build in the open
Work with us
Tech transferNative apps in Rust and eguiWebsite build10 languages, accounts, docs and downloadsDesktop app buildRust and egui, no WebViewRelease and payment pipelineSigning, MSI, deb, rpm, AppImage, hashesSales partnerRecommend us and earn 30%ContactBuilds, partnerships and investment
Services
Remote desktopReach your computer from a browserCustom installer packagesOnly the features you need, settings preloaded
Buy
EN
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Log in
Log in
TASTEDEV

From small tools to better development.

support@tastedev.netSupport TASTEDEV
ProductsProduct lineupBuyDocsDownloadsMarketplaceSupport
CommunityProjectsDevelopment logsPromptsAI tool issuesShowcase
PoliciesAbout usPrivacy policyTerms of serviceSubscription termsRefund policyCommunity guidelines
AccountLog inSign up
Visitors
Today
Yesterday
Total views
Company
GXSOFT
Representative
CHOI YOUNG GU
Business registration number
853-44-00368
Address
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Phone
+82-10-4404-1523
Email
whitecalvin@tastedev.net
Privacy officer
CHOI YOUNG GU

© 2026 TASTEDEVProduct information is based on verified development sources.Released · improving

Spring Boot docs
Spring Boot
Getting Started with Spring BootProject Structure and ConfigurationCore ConceptsData and StateTestingDeployment
Discussions

Spring Boot guide · 4/6

Data and State

A Spring Boot server usually keeps no state in memory between requests; it lives in a database. This chapter shows how to work with data through Spring Data JPA, keep it consistent with transactions, validate input and manage the schema with Flyway.

Dependencies and connection settings

For PostgreSQL, add these dependencies (in Initializr: data-jpa, postgresql, flyway and validation):

dependencies {
    implementation("org.springframework.boot:spring-boot-starter-data-jpa")
    implementation("org.springframework.boot:spring-boot-starter-validation")
    implementation("org.springframework.boot:spring-boot-starter-flyway")
    implementation("org.flywaydb:flyway-database-postgresql")
    runtimeOnly("org.postgresql:postgresql")
}

Connection details go under spring.datasource.*. Let Flyway own the schema and have Hibernate only check that entities match the tables:

spring:
  datasource:
    url: jdbc:postgresql://localhost:5432/demo
    username: demo
    password: ${DB_PASSWORD}
  jpa:
    hibernate:
      ddl-auto: validate
    open-in-view: false

Entities and repositories

An entity maps to a table row. JPA needs a no-argument constructor, so add a protected one.

@Entity
public class Todo {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @Column(nullable = false, length = 200)
    private String title;

    private boolean done;

    protected Todo() {}

    public Todo(String title) { this.title = title; }

    public void complete() { this.done = true; }

    public Long getId() { return id; }
    public String getTitle() { return title; }
    public boolean isDone() { return done; }
}

For a repository you declare only an interface; Spring Data generates the implementation. JpaRepository provides save, findById, findAll, deleteById and more, and method names can be turned into queries:

public interface TodoRepository extends JpaRepository<Todo, Long> {

    List<Todo> findByDoneFalseOrderByIdAsc();

    @Query("select t from Todo t where lower(t.title) like lower(concat('%', :keyword, '%'))")
    List<Todo> search(@Param("keyword") String keyword);
}

Transactions

The service layer is where operations are grouped into units of work. A @Transactional method opens a transaction on entry, commits on normal return and rolls back on a runtime exception. Changes to an entity loaded inside the transaction are flushed at commit without calling save (dirty checking).

@Service
@Transactional(readOnly = true)
public class TodoService {

    private final TodoRepository repository;

    public TodoService(TodoRepository repository) {
        this.repository = repository;
    }

    public List<Todo> open() {
        return repository.findByDoneFalseOrderByIdAsc();
    }

    @Transactional
    public void complete(Long id) {
        Todo todo = repository.findById(id)
            .orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND));
        todo.complete();
    }
}

Two pitfalls: checked exceptions do not trigger a rollback by default, so use rollbackFor when needed; and because @Transactional works through a proxy, calling another method of the same class directly bypasses it.

Validating input

Put Bean Validation constraints on the request type and @Valid on the controller parameter. Invalid requests are rejected with a 400 response before your method runs.

public record CreateTodo(@NotBlank @Size(max = 200) String title) {}

@PostMapping
public TodoResponse create(@Valid @RequestBody CreateTodo request) {
    return service.create(request.title());
}

To shape the error body, handle MethodArgumentNotValidException in a @RestControllerAdvice and return a ProblemDetail (the RFC 9457 format).

Managing the schema with Flyway

Flyway runs the SQL files in src/main/resources/db/migration in version order and records what it applied in the flyway_schema_history table. On startup it runs only the files that have not been applied yet.

-- src/main/resources/db/migration/V1__create_todo.sql
create table todo (
    id    bigint generated by default as identity primary key,
    title varchar(200) not null,
    done  boolean not null default false
);

Never edit a migration that has already been applied. Add a new file such as V2__add_due_date.sql instead.

Summary

  • An interface extending JpaRepository gives you CRUD operations and derived queries.
  • Put @Transactional on service methods to define transactions.
  • Add constraints to request types and validate them with @Valid.
  • Manage the schema with Flyway migrations and set Hibernate to validate.
Questions about this chapter?
Previous chapterCore ConceptsNext chapterTesting

0 comments

Top commentsNewest first

Sign in · Sign in to leave a comment.