Tech News
← Back to articles

SQG (SQL to Code Generator) Now with Java Streams and List Type Support

read original related products more articles

SQG is a type-safe SQL code generator — you write .sql files with annotated queries, and it generates strongly-typed database access code for TypeScript and Java by introspecting your queries against real database engines at build time.

Here’s what’s new in v0.10.0.

Generated Java code now includes methods that return Stream in addition to List . This gives you lazy evaluation, easier composition with the standard library, and avoids materializing large result sets into memory when you don’t need to.

try ( Stream < User > users = queries . getAllUsersStream () ) { users . forEach ( user -> process ( user )) ; }

The stream holds a reference to the underlying ResultSet , so it needs to be closed after use — hence the try-with-resources.

Array columns like TEXT[] or INTEGER[] are now handled correctly in generated Java code. Previously these types could produce incorrect mappings — they now resolve to proper List , List , etc.

DuckDB: List types in Appender Section titled “DuckDB: List types in Appender”

The DuckDB appender now supports list/array column types. If your table has a column like tags VARCHAR[] , the generated appender method accepts the corresponding list type and writes it correctly using DuckDB’s bulk insert API.

Upgrade with npm install -g @sqg/[email protected] or update your project’s dependency. Full source on GitHub. Try it out in the playground.

Discuss this on Hackernews.