compositesAsMaps
A converter that reads every composite as a Map<String, Any?>, whatever it is registered as.
Registration is global to the database - it is what a composite is to every session pointing there - so it is not where one report saying "give me the shape, not my classes" can be answered. This is: register it on the query and it applies to that query and is discarded with it.
session.createNativeQuery("SELECT * FROM veterans")
.registerResultConverter(compositesAsMaps())
.fetchObjects<Map<String, Any?>>()It collapses the whole subtree, which it gets for free rather than by walking one: attributes are converted as Any?, a nested composite asked for as Any? reaches this same converter again, and an array of composites hands its elements down the same way. An anonymous ROW(...) already answers to a map on its own. A composite registered nowhere collapses along with the rest, which is what stops one turning up as a raw PgComposite three levels down - the one place asking for Map<String, Any?> does not reach today.
Naming a class still gets you the class. This claims a value only where the caller asked for Any or Map - which is what "no preference" and "a dictionary" look like - so row.get<Address>("residence") in the same query is untouched. What changes is the default view of a composite, not what an explicit ask means.
Return
A converter to hand to registerResultConverter on a query.
See also
for the one-type form.
The same, for one composite type: values of that type come back as maps and every other composite still maps onto whatever class it is registered as.
session.createNativeQuery("SELECT assessment FROM censuses")
.registerResultConverter(compositesAsMaps("tribute"))
.fetchField<Map<String, Any?>>() // {label=census, payload={amount=40, currency=denarius}}The type is matched where it is met, so a tribute nested inside an assessment collapses as well and the assessment around it does not. For several types, name them all in one of these rather than registering one apiece - see the Collection overload.
Return
A converter to hand to registerResultConverter on a query.
Parameters
The composite type's name in PostgreSQL.
Its schema. Left empty, the name matches whichever schema the value came from, which is the right reading when the type is reached through the search path rather than written out.
The same, for several named types at once.
Prefer this to registering one converter per type: every converter on the query is asked about every composite it decodes, and this is one of them however many names it holds. At a handful of types the difference is not measurable against what decoding a composite costs anyway; by fifty it is about a third of the lookup, the array scan here being cheaper than fifty calls through a registry.
Return
A converter to hand to registerResultConverter on a query.
Parameters
The composite types to collapse. A QualifiedName with an empty schema matches the name wherever the value came from.