# RoomWarnings

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

*** ** * ** ***

Common/AllAndroid/JVMNative/C/iOSJavaScript
- Cmn

  ```
  open class RoomWarnings
  ```

*** ** * ** ***

The list of warnings that are produced by Room.

You can use these values inside a SuppressWarnings annotation to disable the warnings.

## Summary

| ### Constants |
|---|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/room/RoomWarnings#AMBIGUOUS_COLUMN_IN_RESULT()` Reported when there is an ambiguous column on the result of a multimap query. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/room/RoomWarnings#CANNOT_CREATE_VERIFICATION_DATABASE()` Reported when Room cannot verify database queries during compilation. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/room/RoomWarnings#CURSOR_MISMATCH()` **This property is deprecated.** Replaced by QUERY_MISMATCH. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/room/RoomWarnings#DEFAULT_CONSTRUCTOR()` Reported when a POJO has multiple constructors, one of which is a no-arg constructor. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/room/RoomWarnings#DOES_NOT_IMPLEMENT_EQUALS_HASHCODE()` The warning dispatched by Room when the object in the provided method's multimap return type does not implement equals() and hashCode(). | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/room/RoomWarnings#INDEX_FROM_EMBEDDED_ENTITY_IS_DROPPED()` Reported when an `https://developer.android.com/reference/kotlin/androidx/room/Entity` that has a `https://developer.android.com/reference/kotlin/androidx/room/Embedded` field whose type is another `https://developer.android.com/reference/kotlin/androidx/room/Entity` and that `https://developer.android.com/reference/kotlin/androidx/room/Entity` has some indices defined. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/room/RoomWarnings#INDEX_FROM_EMBEDDED_FIELD_IS_DROPPED()` Reported when an `https://developer.android.com/reference/kotlin/androidx/room/Entity` field that is annotated with `https://developer.android.com/reference/kotlin/androidx/room/Embedded` has a sub field which has a `https://developer.android.com/reference/kotlin/androidx/room/ColumnInfo` annotation with `index = true`. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/room/RoomWarnings#INDEX_FROM_PARENT_FIELD_IS_DROPPED()` Reported when an `https://developer.android.com/reference/kotlin/androidx/room/Entity` inherits a field from its super class and the field has a `https://developer.android.com/reference/kotlin/androidx/room/ColumnInfo` annotation with `index = true`. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/room/RoomWarnings#INDEX_FROM_PARENT_IS_DROPPED()` Reported when an `https://developer.android.com/reference/kotlin/androidx/room/Entity`'s parent declares an `https://developer.android.com/reference/kotlin/androidx/room`. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/room/RoomWarnings#MISMATCHED_GETTER()` Reported when an `@Entity` field's type do not exactly match the getter type. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/room/RoomWarnings#MISMATCHED_SETTER()` Reported when an `@Entity` field's type do not exactly match the setter type. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/room/RoomWarnings#MISSING_INDEX_ON_FOREIGN_KEY_CHILD()` When there is a foreign key from Entity A to Entity B, it is a good idea to index the reference columns in B, otherwise, each modification on Entity A will trigger a full table scan on Entity B. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/room/RoomWarnings#MISSING_INDEX_ON_JUNCTION()` Reported when a junction entity whose column is used in a `@Relation` field with a `@Junction` does not contain an index. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/room/RoomWarnings#MISSING_JAVA_TMP_DIR()` Reported when Room cannot verify database queries during compilation due to lack of tmp dir access in JVM. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/room/RoomWarnings#MISSING_SCHEMA_LOCATION()` Reported when a `room.schemaLocation` argument is not provided into the annotation processor. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/room/RoomWarnings#PRIMARY_KEY_FROM_EMBEDDED_IS_DROPPED()` Reported when an `https://developer.android.com/reference/kotlin/androidx/room/Entity` field that is annotated with `https://developer.android.com/reference/kotlin/androidx/room/Embedded` has a sub field which is annotated with `https://developer.android.com/reference/kotlin/androidx/room/PrimaryKey` but the `https://developer.android.com/reference/kotlin/androidx/room/PrimaryKey` is dropped while composing it into the parent object. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/room/RoomWarnings#QUERY_MISMATCH()` The warning dispatched by Room when the return value of a `https://developer.android.com/reference/kotlin/androidx/room/Query` method does not exactly match the columns in the query result. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/room/RoomWarnings#RELATION_QUERY_WITHOUT_TRANSACTION()` Reported when a @Query method returns a POJO that has relations but the method is not annotated with @Transaction. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/room/RoomWarnings#RELATION_TYPE_MISMATCH()` Reported when a `https://developer.android.com/reference/kotlin/androidx/room/Entity`'s SQLite column type does not match the type in the parent. | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/room/RoomWarnings#UNNECESSARY_NULLABILITY_IN_DAO_RETURN_TYPE()` Reported when a nullable Collection, Array or Optional is returned from a DAO method. | Cmn |

| ### Public constructors |
|---|---|
| `[RoomWarnings](https://developer.android.com/reference/kotlin/androidx/room/RoomWarnings#RoomWarnings())()` **This function is deprecated.** This type should not be instantiated as it contains only static methods. | Cmn |

## Constants

### AMBIGUOUS_COLUMN_IN_RESULT

Cmn

```
const val AMBIGUOUS_COLUMN_IN_RESULT: String
```

Reported when there is an ambiguous column on the result of a multimap query.

### CANNOT_CREATE_VERIFICATION_DATABASE

Cmn

```
const val CANNOT_CREATE_VERIFICATION_DATABASE: String
```

Reported when Room cannot verify database queries during compilation. This usually happens when it cannot find the SQLite JDBC driver on the host machine.

Room can function without query verification but its functionality will be limited.

### CURSOR_MISMATCH

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

```
const val CURSOR_MISMATCH: String
```

> [!CAUTION]
> **This property is deprecated.**   
> Replaced by QUERY_MISMATCH, use this instead:
>
> ```kotlin
> QUERY_MISMATCH
> ```

The warning dispatched by Room when the return value of a `https://developer.android.com/reference/kotlin/androidx/room/Query` method does not exactly match the fields in the query result.

### DEFAULT_CONSTRUCTOR

Cmn

```
const val DEFAULT_CONSTRUCTOR: String
```

Reported when a POJO has multiple constructors, one of which is a no-arg constructor. Room will pick that one by default but will print this warning in case the constructor choice is important. You can always guide Room to use the right constructor using the @Ignore annotation.

### DOES_NOT_IMPLEMENT_EQUALS_HASHCODE

Cmn

```
const val DOES_NOT_IMPLEMENT_EQUALS_HASHCODE: String
```

The warning dispatched by Room when the object in the provided method's multimap return type does not implement equals() and hashCode().

### INDEX_FROM_EMBEDDED_ENTITY_IS_DROPPED

Cmn

```
const val INDEX_FROM_EMBEDDED_ENTITY_IS_DROPPED: String
```

Reported when an `https://developer.android.com/reference/kotlin/androidx/room/Entity` that has a `https://developer.android.com/reference/kotlin/androidx/room/Embedded` field whose type is another `https://developer.android.com/reference/kotlin/androidx/room/Entity` and that `https://developer.android.com/reference/kotlin/androidx/room/Entity` has some indices defined. These indices will NOT be created in the containing `https://developer.android.com/reference/kotlin/androidx/room/Entity`. If you want to preserve them, you can re-define them in the containing `https://developer.android.com/reference/kotlin/androidx/room/Entity`.

### INDEX_FROM_EMBEDDED_FIELD_IS_DROPPED

Cmn

```
const val INDEX_FROM_EMBEDDED_FIELD_IS_DROPPED: String
```

Reported when an `https://developer.android.com/reference/kotlin/androidx/room/Entity` field that is annotated with `https://developer.android.com/reference/kotlin/androidx/room/Embedded` has a sub field which has a `https://developer.android.com/reference/kotlin/androidx/room/ColumnInfo` annotation with `index = true`.

You can re-define the index in the containing `https://developer.android.com/reference/kotlin/androidx/room/Entity`.

### INDEX_FROM_PARENT_FIELD_IS_DROPPED

Cmn

```
const val INDEX_FROM_PARENT_FIELD_IS_DROPPED: String
```

Reported when an `https://developer.android.com/reference/kotlin/androidx/room/Entity` inherits a field from its super class and the field has a `https://developer.android.com/reference/kotlin/androidx/room/ColumnInfo` annotation with `index = true`.

These indices are dropped for the `https://developer.android.com/reference/kotlin/androidx/room/Entity` and you would need to re-declare them if you want to keep them. Alternatively, you can set `https://developer.android.com/reference/kotlin/androidx/room/Entity#inheritSuperIndices()` to `true`.

### INDEX_FROM_PARENT_IS_DROPPED

Cmn

```
const val INDEX_FROM_PARENT_IS_DROPPED: String
```

Reported when an `https://developer.android.com/reference/kotlin/androidx/room/Entity`'s parent declares an `https://developer.android.com/reference/kotlin/androidx/room`. Room does not automatically inherit these indices to avoid hidden costs or unexpected constraints.

If you want your child class to have the indices of the parent, you must re-declare them in the child class. Alternatively, you can set `https://developer.android.com/reference/kotlin/androidx/room/Entity#inheritSuperIndices()` to `true`.

### MISMATCHED_GETTER

Cmn

```
const val MISMATCHED_GETTER: String
```

Reported when an `@Entity` field's type do not exactly match the getter type. For instance, in the following class:

```kotlin
@Entity
class Foo {
    ...
    private val value: Boolean
    public fun getValue(): Boolean {
        return value == null ? false : value
    }
}
```

Trying to insert this entity into database will always set `value` column to `false` when `Foo.value` is `null` since Room will use the `getValue` method to read the value. So even thought the database column is nullable, it will never be inserted as `null` if inserted as a `Foo` instance.

### MISMATCHED_SETTER

Cmn

```
const val MISMATCHED_SETTER: String
```

Reported when an `@Entity` field's type do not exactly match the setter type. For instance, in the following class:

```kotlin
@Entity
class Foo {
    ...
    private val value: Boolean
    public fun setValue(value: Boolean) {
        this.value = value
    }
}
```

If Room reads this entity from the database, it will always set `Foo.value` to `false` when the column value is `null` since Room will use the `setValue` method to write the value.

### MISSING_INDEX_ON_FOREIGN_KEY_CHILD

Cmn

```
const val MISSING_INDEX_ON_FOREIGN_KEY_CHILD: String
```

When there is a foreign key from Entity A to Entity B, it is a good idea to index the reference columns in B, otherwise, each modification on Entity A will trigger a full table scan on Entity B.

If Room cannot find a proper index in the child entity (Entity B in this case), Room will print this warning.

### MISSING_INDEX_ON_JUNCTION

Cmn

```
const val MISSING_INDEX_ON_JUNCTION: String
```

Reported when a junction entity whose column is used in a `@Relation` field with a `@Junction` does not contain an index. If the column is not covered by any index then a full table scan might be performed when resolving the relationship.

It is recommended that columns on entities used as junctions contain indices, otherwise Room will print this warning.

### MISSING_JAVA_TMP_DIR

Cmn

```
const val MISSING_JAVA_TMP_DIR: String
```

Reported when Room cannot verify database queries during compilation due to lack of tmp dir access in JVM.

### MISSING_SCHEMA_LOCATION

Cmn

```
const val MISSING_SCHEMA_LOCATION: String
```

Reported when a `room.schemaLocation` argument is not provided into the annotation processor. You can either set `https://developer.android.com/reference/kotlin/androidx/room/Database#exportSchema()` to `false` or provide `room.schemaLocation` to the annotation processor. You are strongly advised to provide it and also commit them into your version control system.

### PRIMARY_KEY_FROM_EMBEDDED_IS_DROPPED

Cmn

```
const val PRIMARY_KEY_FROM_EMBEDDED_IS_DROPPED: String
```

Reported when an `https://developer.android.com/reference/kotlin/androidx/room/Entity` field that is annotated with `https://developer.android.com/reference/kotlin/androidx/room/Embedded` has a sub field which is annotated with `https://developer.android.com/reference/kotlin/androidx/room/PrimaryKey` but the `https://developer.android.com/reference/kotlin/androidx/room/PrimaryKey` is dropped while composing it into the parent object.

### QUERY_MISMATCH

Cmn

```
const val QUERY_MISMATCH: String
```

The warning dispatched by Room when the return value of a `https://developer.android.com/reference/kotlin/androidx/room/Query` method does not exactly match the columns in the query result.

### RELATION_QUERY_WITHOUT_TRANSACTION

Cmn

```
const val RELATION_QUERY_WITHOUT_TRANSACTION: String
```

Reported when a @Query method returns a POJO that has relations but the method is not annotated with @Transaction. Relations are run as separate queries and if the query is not run inside a transaction, it might return inconsistent results from the database.

### RELATION_TYPE_MISMATCH

Cmn

```
const val RELATION_TYPE_MISMATCH: String
```

Reported when a `https://developer.android.com/reference/kotlin/androidx/room/Entity`'s SQLite column type does not match the type in the parent. Room will still do the matching using `String` representations.

### UNNECESSARY_NULLABILITY_IN_DAO_RETURN_TYPE

Cmn

```
const val UNNECESSARY_NULLABILITY_IN_DAO_RETURN_TYPE: String
```

Reported when a nullable Collection, Array or Optional is returned from a DAO method. Room will return an empty Collection, Array or Optional respectively if no results are returned by such a query, hence using a nullable return type is unnecessary in this case.

## Public constructors

### RoomWarnings

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

```
[RoomWarnings](https://developer.android.com/reference/kotlin/androidx/room/RoomWarnings#RoomWarnings())()
```

> [!CAUTION]
> **This function is deprecated.**   
> This type should not be instantiated as it contains only static methods.