What’s New in tinystruct 1.7.32
This document highlights the new features, improvements, and changes introduced in tinystruct version 1.7.32.
See also: What’s New in 1.7.31 for the previous release featuring PostgreSQL SSL/schema support and performance improvements.
Highlights of 1.7.32
- Expanded Data Type Support: New
UUIDandJSONBfield types added toFieldType, enabling native PostgreSQL-type mapping in POJO generators and ORM layer. FieldInfoRefactored to Pure POJO:FieldInfono longer extendsHashMap. It is now a strongly-typed, high-performance value object with explicit fields and a compatibility facade.- Unified Generator Type Handling: All POJO generators (MySQL, PostgreSQL, SQLite, H2, MSSQL) share the same expanded
FieldTypeconstants, ensuring consistent code generation across database engines.
Major New Features & Enhancements
1. New FieldType Constants: UUID and JSONB
Two new constants have been added to FieldType to improve first-class support for PostgreSQL-native column types:
| Constant | SQL Type | Java Mapping | Notes |
|---|---|---|---|
FieldType.UUID |
UUID |
String |
Mapped via Types.OTHER; used by PostgreSQL UUID columns |
FieldType.JSONB |
JSONB |
String |
Mapped identically to FieldType.JSON; PostgreSQL binary JSON |
These constants are now recognized by PostgreSQLGenerator and all other generators that inherit from the shared type registry, ensuring accurate Java type emission in generated POJO classes.
Example — Generated field for a UUID column
// Before 1.7.32: UUID columns were emitted as Object or fell back to String
// After 1.7.32: correctly typed and annotated
@Column(name = "id", type = "UUID")
private String id;
2. FieldInfo Refactored: HashMap Dependency Removed
FieldInfo has been completely redesigned as a proper value object. It no longer extends HashMap<String, Object>, eliminating the associated memory overhead and eliminating subtle bugs caused by treating metadata as a general-purpose map.
What changed
| Before (≤ 1.7.31) | After (1.7.32) |
|---|---|
Extended HashMap<String, Object> |
Implements Serializable only |
| Column attributes stored as map entries | Explicit private fields with accessors |
| No type safety on attribute access | Fully typed getters/setters |
| No serial UID | serialVersionUID = 1L defined |
Key fields now explicitly typed
public class FieldInfo implements Serializable {
private String name; // logical field name
private String columnName; // actual DB column name
private Object value; // row value
private FieldType type; // resolved FieldType
private int length; // column max length
private boolean autoIncrement; // auto-increment flag
private boolean autoGenerated; // UUID auto-generate flag
// ...
}
Compatibility facade preserved
String-key methods (append(String, Object), set(String, Object), get(String)) are kept as a compatibility facade so existing code using dynamic attribute access continues to work without modification.
Default timestamp fallback
A well-defined sentinel timestamp (1982-03-20 00:00:00.0) is now used when a timestamp-type field value is empty or unset, replacing previous undefined behavior.
3. Unified POJO Generator Type Handling
All five POJO generators have been updated to use the expanded, shared FieldType constants:
| Generator | Database |
|---|---|
MySQLGenerator |
MySQL / MariaDB |
PostgreSQLGenerator |
PostgreSQL |
SQLiteGenerator |
SQLite |
H2Generator |
H2 (embedded) |
MSSQLGenerator |
Microsoft SQL Server |
Previously, each generator duplicated its own type-mapping logic with minor inconsistencies. They now converge on the FieldType registry, ensuring that type names and Java mappings are identical regardless of the target database.
4. Improved FieldInfo Test Coverage
A comprehensive JUnit 5 test class (FieldInfoTest) has been added covering:
- Constructor variants (no-arg, name-only, name+value).
- All typed getter/setter round-trips.
autoIncrementandautoGeneratedflag behavior.- Default timestamp sentinel usage.
- Compatibility facade method (
append,set,get).
Migration Guide
Updating to 1.7.32
Update your pom.xml dependency to version 1.7.32:
<dependency>
<groupId>org.tinystruct</groupId>
<artifactId>tinystruct</artifactId>
<version>1.7.32</version>
</dependency>
FieldInfo Migration Notes
If your code directly casts FieldInfo to Map or calls Map-specific methods (entrySet(), containsKey(), etc.) on a FieldInfo instance, you must update those call sites:
// Before (no longer compiles — FieldInfo is not a Map)
Map<String, Object> map = (Map<String, Object>) fieldInfo;
Object val = map.get("value");
// After — use typed accessors directly
Object val = fieldInfo.getValue();
All other FieldInfo usages through the standard append/set/get facade remain source-compatible.
Community and Resources
- GitHub Repository: https://github.com/tinystruct/tinystruct
- Official Documentation: https://tinystruct.org
- Examples: https://github.com/tinystruct/tinystruct-examples
- Project Archetype: https://github.com/tinystruct/tinystruct-archetype