Urgent.News

What's breaking now, across hundreds of outlets.

Tech

JDBC Mapping Without Reflection: Up to 117 Faster Than Spring JDBC

SQL execution isn't the only cost of a database query. Turning a ResultSet into Java objects costs time and memory, too. What if we generated the mapping code at compile time instead? That's what SJF4J does with @CompiledJdbcMapper . A simple example Define a Java record: public record User ( long id , String userName , int age ) { } Declare a mapper: @CompiledJdbcMapper public interface…

Mapping database results to Java objects can be costly both in terms of time and memory. SJF4J offers a solution by generating mapping code at compile time with the @CompiledJdbcMapper annotation. To use it, define a Java record and declare a mapper interface. The mapper can be accessed via the INSTANCE field, and the users method takes a ResultSet as input.

Consider a benchmark comparing SJF4J against Spring JDBC and MyBatis using a 12-column result set with 1,000 rows. The results show that SJF4J is up to 117 times faster than Spring JDBC and nearly 118 times faster than MyBatis when mapping Java records. SJF4J also allocates 50 times less memory than Spring's DataClassRowMapper.

SJF4J generates specialized Java code at compile time, eliminating the need for runtime object mapping. This results in faster column index resolution, typed JDBC getters, and direct object creation. The generated code closely resembles handwritten JDBC mapping, outperforming general-purpose reflective mappers.

For those who prefer to control the row loop, SJF4J also supports prepared row mapping. An interface with a prepare method takes a ResultSetMetaData and can be used to map individual rows as needed. SJF4J does not replace SQL frameworks or manage database connections; it simply accelerates the ResultSet-to-object conversion process, allowing developers to keep their SQL and JDBC code intact.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

Install Nginx on Ubuntu (AWS EC2): Start It, Enable It, Check It

My Node app runs on port 4000. That means anyone who opens it has to type :4000 at the end of the URL. Real sites don't work like that. The fix is to put a web server in front of the app.

  • Install Nginx on Ubuntu EC2 using sudo apt install -y nginx
  • Start Nginx service with sudo systemctl start nginx
  • Verify Nginx status with sudo systemctl status nginx

Why We Built an RMM Priced Per Device, From $0.50

If you've ever shopped for RMM (remote monitoring and management) software as a one-person IT shop, you've probably had the same experience: every vendor wants to talk about "per-technician pricing,"…

  • OniConnect offers per-device pricing starting at $0.50 per device per month.
  • Designed for solo admins and small MSPs managing 20-500 endpoints.
  • Transparent pricing eliminates need for sales calls or demos.

Pattern Matching on Spans and UTF-8 Literals in C# 15 / .NET 11

High-throughput network parsers (Kestrel, custom TCP, Kafka consumers) read wire data as ReadOnlySpan . Historically, running a clean switch statement on headers or commands required either string…

  • C# 15 introduces direct switch pattern matching on byte spans
  • Eliminates zero allocations and Gen0 garbage collection pressure
  • Improves code readability with idiomatic pattern matching syntax

How a Query Planner Chooses the Fastest Path

SQL is declarative. You write what you want: "the names of customers in Oran who ordered this month". You do not write how to get it: which table to read first, whether to use an index, how to combine…

  • Query optimizer, or query planner, selects fastest SQL query execution path.
  • Joins methods like nested loop, hash join, and merge join considered.
  • Planner uses cost-based approach with statistics for efficient query planning.

More from Tuesday, 1 December 2026 →