SShortSingh.
Back to feed

JPA/Hibernate Entity Lifecycle: The 4 States Every Java Developer Must Know

0
·1 views

JPA and Hibernate manage entity objects through four distinct lifecycle states that are frequently tested in Java technical interviews. An entity begins in the Transient state when created with the 'new' keyword, existing only in JVM heap memory with no database or persistence context awareness. It moves to the Persistent state upon being saved or fetched, where Hibernate's Dirty Checking automatically syncs field changes to the database on transaction commit without requiring an explicit save call. Once a transaction ends or the entity is manually detached, it enters the Detached state, where changes are no longer tracked and must be re-attached via merge to sync with the database. Finally, calling entityManager.remove() places the entity in the Removed state, marking it for deletion from the database when the transaction commits.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Pin Error Contracts With Characterization Tests Before AI-Assisted Refactors

AI coding tools often suggest consolidating error-handling logic during refactors, preferring a single exception type or replacing None returns with raises — but this can silently break production callers that already depend on multiple distinct error shapes. A dispatcher function may legitimately return None, raise a ValueError, or return a status-keyed dict, and downstream code branches on all three outcomes. The real risk in such refactors is an unrecorded error taxonomy, not missing type annotations. The recommended safeguard is to write characterization tests that pin each fixture's exception type, return shape, status integer, and warning log count before touching any except clause. Only once those tests stay green should a single except clause be changed at a time.

0
ProgrammingDEV Community ·

NovelAI V5 on Opus: Free up to Normal size, Anlas reset starts Sept 21, 2026

NovelAI's top-tier Opus subscribers can generate images with Diffusion V5 at no Anlas cost up to Normal size (832×1216) at 28 steps per request, but Large size (1024×1536) deducts 45 Anlas from the subscription balance. Starting September 21, 2026 — 31 days after V5's August 21 launch — any unused subscription Anlas will be wiped to zero at the end of each billing period, though separately purchased Anlas is unaffected. NovelAI has also migrated its balance API endpoint from api.novelai.net to image.novelai.net, with the old address now returning a 400 error directing users to update their tools. A rechargeable battery-style usage cap applies exclusively to V5, refilling automatically over roughly a week, while older image models and text models remain unlimited. Developers using third-party tools such as ComfyUI nodes should update their endpoint configurations to avoid disruption.

0
ProgrammingDEV Community ·

Four Local LLM Inference Engines Developers Should Know in 2026

By late 2026, advances in quantization algorithms and specialized inference runtimes have made running large language models feasible on standard developer workstations. Tools like Ollama have emerged as popular choices for individual developers, offering a streamlined setup with a Docker-like model registry and an OpenAI-compatible REST API for easy IDE integration. For engineering teams needing high-throughput concurrent serving, vLLM provides capabilities such as PagedAttention memory management, continuous batching, and multi-GPU tensor parallelism. These engines now address distinct workflows, from desktop simplicity and agent backends to production-grade parallel inference across shared team infrastructure. The shift reduces reliance on cloud compute budgets and subscription APIs while enabling low-latency, privacy-preserving AI execution on local hardware.

0
ProgrammingDEV Community ·

Five Open-Source Self-Hosted Tools Engineering Teams Should Deploy in 2026

Engineering teams in 2026 are increasingly turning to self-hosted infrastructure to avoid rising cloud subscription costs, vendor lock-in, and data sovereignty concerns. The self-hosting ecosystem has matured significantly, with modern tools offering single-binary deployments, containerized orchestration, and automated security features. Among the top recommended tools are Caddy, a Go-based web server that automates TLS certificate management, and Forgejo, a lightweight community-governed code forge that supports CI/CD workflows and package registries. Both tools are designed to run efficiently on modest hardware, with Forgejo consuming under 150 MB of RAM under moderate workloads. Together, these open-source solutions aim to give engineering teams enterprise-grade reliability without dependence on commercial cloud platforms.