Skip to main content

5.5 Map Query Mode

Map Query Mode is a way to use the Builder API with Map<String, Object> as the data carrier. Mapped Map Mode reuses entity object mapping, while Freedom Map Mode uses table and column names directly.

Suitable For

  • Data comes from dynamic forms, imports, messages, or intermediate transformation results.
  • Query, insert, update, and delete operations should use the same builder API with Map data.
  • Object mapping already exists, but the application layer does not want entity objects.
  • There is no entity class, or table and column names come from configuration or runtime rules.

Not Suitable For

Two Map Modes

ModeEntranceRequires object mappingField interpretationDetails
Mapped Map Modelambda.query(User.class).asMap()YesJava property names, converted by mappingMapped Map Mode
Freedom Map Modelambda.queryFreedom("users")NoTable and column names come directly from stringsFreedom Map Mode
Choose a mode
Entity mapping exists
|
+-- Need Map as row carrier
| |
| +-- Use asMap()
|
+-- Need entity objects and method references
|
+-- Use Entity mode

No entity mapping
|
+-- Caller provides table and column names
|
+-- Use *Freedom()

Both modes use the same MapQuery, MapInsert, MapUpdate, and MapDelete APIs. Shared capabilities include conditions, ordering, grouping, paging, insert, update, delete, and unsafe-update protection.

Query And Write Entrances

OperationMapped Map ModeFreedom Map Mode
Querylambda.query(User.class).asMap()lambda.queryFreedom("users")
Insertlambda.insert(User.class).asMap()lambda.insertFreedom("users")
Updatelambda.update(User.class).asMap()lambda.updateFreedom("users")
Deletelambda.delete(User.class).asMap()lambda.deleteFreedom("users")

See Map Insert, Update, And Delete for operation details.

Field Sources

Field interpretation
Mapped Map Mode
Map key = Java property name
loginName -> object mapping -> login_name

Freedom Map Mode
Map key = caller-provided column name
login_name -> SQL identifier

Mapped Map Mode reads object mapping, so it can reuse column conversion, field filtering, TypeHandler, and write policies. Freedom Map Mode does not read entity mapping; the caller provides table and column names directly.

Further Reading