# MapInfo

Artifact: [androidx.room:room-common](https://developer.android.com/jetpack/androidx/releases/room) [View Source](https://cs.android.com/search?q=file:androidx/room/MapInfo.kt+class:androidx.room.MapInfo) Added in [2.4.0](https://developer.android.com/jetpack/androidx/releases/room#2.4.0) Deprecated in [2.6.0](https://developer.android.com/jetpack/androidx/releases/room#2.6.0)

*** ** * ** ***

Common/AllAndroid/JVMNative/C/iOSJavaScript
- Cmn

  ```
  @Target(allowedTargets = [AnnotationTarget.FUNCTION])
  @Retention(value = AnnotationRetention.BINARY)
  annotation MapInfo
  ```

*** ** * ** ***

> [!CAUTION]
> **This annotation is deprecated.**   
> Use @MapColumn instead.

Declares which column(s) are used to build a map or multimap return value in a `https://developer.android.com/reference/kotlin/androidx/room/Dao` query method.

This annotation is required when the key or value of the Map is a single column of one of the built in types (primitives, boxed primitives, enum, String, byte\[\], ByteBuffer) or a type with a converter (e.g. Date, UUID, etc).

The use of this annotation provides clarity on which column should be used in retrieving information required by the return type.

Example:

```kotlin
@MapInfo(keyColumn = "artistName", valueColumn = "songName")
@Query("SELECT * FROM Artist JOIN Song ON Artist.artistName = Song.artist")
fun getArtistNameToSongNames(): Map<String, List<String>>

@MapInfo(valueColumn = "songCount")
@Query("SELECT *, COUNT(mSongId) as songCount FROM Artist JOIN Song ON
Artist.artistName = Song.artist GROUP BY artistName")
fun getArtistAndSongCounts(): Map<Artist, Integer>
```

To use the @MapInfo annotation, you must provide either the key column name, value column name, or both, based on the `https://developer.android.com/reference/kotlin/androidx/room/Dao`'s method return type. Column(s) specified in the provided @MapInfo annotation must be present in the query result.

## Summary

| ### Public constructors |
|---|---|
| `[MapInfo](https://developer.android.com/reference/kotlin/androidx/room/MapInfo#MapInfo(kotlin.String,kotlin.String,kotlin.String,kotlin.String))( keyColumn: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, keyTable: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, valueColumn: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, valueTable: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html )` **This function is deprecated.** Use @MapColumn instead. | Cmn |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/room/MapInfo#keyColumn()` **This property is deprecated.** Use @MapColumn instead. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/room/MapInfo#keyTable()` **This property is deprecated.** Use @MapColumn instead. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/room/MapInfo#valueColumn()` **This property is deprecated.** Use @MapColumn instead. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/room/MapInfo#valueTable()` **This property is deprecated.** Use @MapColumn instead. | Cmn |

## Public constructors

### MapInfo

Cmn Added in [2.8.5](https://developer.android.com/jetpack/androidx/releases/room#2.8.5) Deprecated in [2.8.5](https://developer.android.com/jetpack/androidx/releases/room#2.8.5)

```
[MapInfo](https://developer.android.com/reference/kotlin/androidx/room/MapInfo#MapInfo(kotlin.String,kotlin.String,kotlin.String,kotlin.String))(
    keyColumn: String = "",
    keyTable: String = "",
    valueColumn: String = "",
    valueTable: String = ""
)
```

> [!CAUTION]
> **This function is deprecated.**   
> Use @MapColumn instead.

## Public properties

### keyColumn

Cmn

```
val keyColumn: String
```

> [!CAUTION]
> **This property is deprecated.**   
> Use @MapColumn instead.

The name of the column to be used for the map's keys.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The key column name. |

### keyTable

Cmn

```
val keyTable: String
```

> [!CAUTION]
> **This property is deprecated.**   
> Use @MapColumn instead.

The name of the table or alias to be used for the map's keys.

Providing this value is optional. Useful for disambiguating between duplicate column names. For example, consider the following query: `SELECT * FROM Artist AS a JOIN Song AS s ON a.id == s.artistId`, then the `@MapInfo` for a return type `Map<String, List<Song>>` would be `@MapInfo(keyColumn = "id", keyTable ="a")`.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The key table name. |

### valueColumn

Cmn

```
val valueColumn: String
```

> [!CAUTION]
> **This property is deprecated.**   
> Use @MapColumn instead.

The name of the column to be used for the map's values.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The value column name. |

### valueTable

Cmn

```
val valueTable: String
```

> [!CAUTION]
> **This property is deprecated.**   
> Use @MapColumn instead.

The name of the table or alias to be used for the map's values.

Providing this value is optional. Useful for disambiguating between duplicate column names. For example, consider the following query: `SELECT * FROM Song AS s JOIN Artist AS a ON s.artistId == a.id`, then the `@MapInfo` for a return type `Map<Song, String>` would be `@MapInfo(valueColumn = "id", valueTable ="a")`.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The key table name. |