Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallWith asentinel-orm, an application can store user-defined attributes as ordinary relational columns without adding a Java field for each one. The pattern pairs a DynamicColumnsEntity implementation that keeps values in a map with runtime column metadata: add the database columns, pass that metadata when updating, and supply it again when reading.
How the pattern works
Keep fields known at compile time in the usual mapped Java properties. Store runtime-defined values separately, keyed by DynamicColumn. That metadata connects each runtime attribute to its database column, much as @Column connects a conventional Java property to a column.
The tutorial applies this to car manufacturers and car models. A manufacturer has ordinary mapped fields and a map of runtime attributes; the model relationship is handled separately. The database schema changes when a user-defined attribute is added, so this approach is dynamic at the application-model level, not schema-free.
Implementation flow
1. Map the fields known at compile time
Use @Table, @PkColumn and @Column for the manufacturer’s fixed fields. Model its relationship to car models with the ORM’s relationship annotation. These mappings remain conventional even though additional columns may be introduced later.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errors2. Expose runtime values through the entity
Subclass or otherwise implement DynamicColumnsEntity<DynamicColumn> for the custom entity. Keep the dynamic values in a map keyed by DynamicColumn, and implement setValue(column, value) and getValue(column). The ORM calls the setter when populating a dynamic value from a query result; the getter supplies that value when it writes the entity.
3. Add a database column and create its metadata
When a user requests an attribute, the tutorial adds its column using ALTER TABLE and records a DefaultDynamicColumn reference for the new attribute. Its example supports int and varchar for simplicity. It assembles the DDL from a user-provided name and type, but does not show validation or identifier quoting. Treat that snippet as an illustration, not as a production-safe schema-change routine: validate allowed names and types, and use database-appropriate identifier handling before executing DDL.
Rank #2
4. Pass metadata when saving
After setting the dynamic values on the entity, include their metadata in the update settings:
orm.update(entity, new UpdateSettings<>(attributes, null));
Here, attributes is the list of dynamic columns associated with the values being written. The ORM needs this list because those attributes are not represented by fixed mapped Java fields.
5. Pass metadata when reading
Build the query with SqlBuilder and use DynamicColumnsEntityNodeCallback, providing a factory for the custom entity and the dynamic-column list. The callback lets the ORM construct the entity and place returned runtime values into it through setValue.
The tutorial also uses AutoEagerLoader to load related car models. That is a separate relationship-loading concern; it is not what enables dynamic attributes.
Rank #4
What this design means for an application
- Schema changes are part of the feature. Each newly supported attribute becomes a relational column through DDL, so the application must coordinate metadata and schema changes.
- Column metadata must be available on reads and writes. The dynamic values alone are not enough: the update settings and read callback both receive the relevant dynamic-column list.
- Type handling is limited in the example. The tutorial illustrates
intandvarchar; it does not establish support for other types or define conversion, validation, or migration policies. - Database-specific safeguards remain your responsibility. Because the shown DDL incorporates a user-supplied name and type, do not accept arbitrary SQL identifiers or type strings from users.
Versions and evidence
Razvan Popian and Horatiu Dan’s DZone tutorial, published December 5, 2024, uses Java 21, Spring Boot 3.4.0, asentinel-orm 1.70.0 and H2. Those are the sample’s environment, not confirmation of the latest releases or current compatibility. The authors describe the approach as using standard database columns and ORM-generated SQL. They also report qualitative production experience, but provide no independently measured benchmark, quantified speedup or named statistical study.
The tutorial’s authors characterize the benefit this way: “While there are probably other ways of working with runtime-defined columns when data is stored in relational databases, the approach presented in this article has the advantage of using standard database columns that are read/written using standard SQL queries generated directly by the ORM.”
Best Value
Read the DZone tutorial by Razvan Popian and Horatiu Dan.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

