# RoomWarnings

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

*** ** * ** ***


```
public static class RoomWarnings
```

<br />

*** ** * ** ***

The list of warnings that are produced by Room.

You can use these values inside a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-suppress/index.html` annotation to disable the warnings.

## Summary

| ### Constants |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/room3/RoomWarnings#AMBIGUOUS_COLUMN_IN_RESULT()` Reported when there is an ambiguous column on the result of a query. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/room3/RoomWarnings#CANNOT_CREATE_VERIFICATION_DATABASE()` Reported when Room cannot verify database queries during compilation. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/room3/RoomWarnings#DEFAULT_CONSTRUCTOR()` Reported when a data class has multiple constructors, one of which is a no-arg constructor. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/room3/RoomWarnings#DOES_NOT_IMPLEMENT_EQUALS_HASHCODE()` The warning dispatched by Room when the object type declared in a `https://developer.android.com/reference/androidx/room3/Query` function's multimap return type does not implement `equals()` and `hashCode()`. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/room3/RoomWarnings#INDEX_FROM_EMBEDDED_ENTITY_IS_DROPPED()` Reported when an `https://developer.android.com/reference/androidx/room3/Entity` that has a `https://developer.android.com/reference/androidx/room3/Embedded` property whose type is another `https://developer.android.com/reference/androidx/room3/Entity` and that `https://developer.android.com/reference/androidx/room3/Entity` has some indices defined. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/room3/RoomWarnings#INDEX_FROM_EMBEDDED_FIELD_IS_DROPPED()` Reported when an `https://developer.android.com/reference/androidx/room3/Entity` property that is annotated with `https://developer.android.com/reference/androidx/room3/Embedded` has a sub property which has a `https://developer.android.com/reference/androidx/room3/ColumnInfo` annotation with `index = true`. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/room3/RoomWarnings#INDEX_FROM_PARENT_FIELD_IS_DROPPED()` Reported when an `https://developer.android.com/reference/androidx/room3/Entity` inherits a property from its super class and the property has a `https://developer.android.com/reference/androidx/room3/ColumnInfo` annotation with `index = true`. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/room3/RoomWarnings#INDEX_FROM_PARENT_IS_DROPPED()` Reported when an `https://developer.android.com/reference/androidx/room3/Entity`'s parent declares an `https://developer.android.com/reference/androidx/room3`. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/room3/RoomWarnings#MISMATCHED_GETTER()` Reported when an `https://developer.android.com/reference/androidx/room3/Entity` property's type do not exactly match the getter type. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/room3/RoomWarnings#MISMATCHED_SETTER()` Reported when an `https://developer.android.com/reference/androidx/room3/Entity` property's type do not exactly match the setter type. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/room3/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. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/room3/RoomWarnings#MISSING_INDEX_ON_JUNCTION()` Reported when a junction entity whose column is used in a `https://developer.android.com/reference/androidx/room3/Relation` property with a `https://developer.android.com/reference/androidx/room3/Junction` does not contain an index. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/room3/RoomWarnings#MISSING_JAVA_TMP_DIR()` Reported when Room cannot verify database queries during compilation due to lack of tmp dir access in JVM. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/room3/RoomWarnings#MISSING_SCHEMA_LOCATION()` Reported when a `room.schemaLocation` argument is not provided into the annotation processor. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `@https://developer.android.com/reference/androidx/room3/ExperimentalRoomApi https://developer.android.com/reference/androidx/room3/RoomWarnings#NO_DATABASE_CONSTRUCTOR()` Reported when a `https://developer.android.com/reference/androidx/room3/Database` annotated declaration is missing `https://developer.android.com/reference/androidx/room3/ConstructedBy` on non-JVM platforms. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/room3/RoomWarnings#PRIMARY_KEY_FROM_EMBEDDED_IS_DROPPED()` Reported when an `https://developer.android.com/reference/androidx/room3/Entity` property that is annotated with `https://developer.android.com/reference/androidx/room3/Embedded` has a sub property which is annotated with `https://developer.android.com/reference/androidx/room3/PrimaryKey` but the `https://developer.android.com/reference/androidx/room3/PrimaryKey` is dropped while composing it into the parent object. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/room3/RoomWarnings#QUERY_MISMATCH()` The warning dispatched by Room when the return value of a `https://developer.android.com/reference/androidx/room3/Query` function does not exactly match the columns in the query result. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/room3/RoomWarnings#RELATION_QUERY_WITHOUT_TRANSACTION()` Reported when a `https://developer.android.com/reference/androidx/room3/Query` function returns a data object that has relations but the function is not annotated with `https://developer.android.com/reference/androidx/room3/Transaction`. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/room3/RoomWarnings#RELATION_TYPE_MISMATCH()` Reported when a `https://developer.android.com/reference/androidx/room3/Entity`'s SQLite column type does not match the type in the parent. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/room3/RoomWarnings#UNNECESSARY_NULLABILITY_IN_DAO_RETURN_TYPE()` Reported when a nullable `Collection`, `Array` or `Optional` is returned from a DAO function. |

| ### Public fields |
|---|---|
| `static @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/room3/RoomWarnings` | `https://developer.android.com/reference/androidx/room3/RoomWarnings#INSTANCE()` |

## Constants

### AMBIGUOUS_COLUMN_IN_RESULT

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public static final @NonNull String AMBIGUOUS_COLUMN_IN_RESULT
```

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

### CANNOT_CREATE_VERIFICATION_DATABASE

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public static final @NonNull String CANNOT_CREATE_VERIFICATION_DATABASE
```

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.

### DEFAULT_CONSTRUCTOR

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public static final @NonNull String DEFAULT_CONSTRUCTOR
```

Reported when a data class 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

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public static final @NonNull String DOES_NOT_IMPLEMENT_EQUALS_HASHCODE
```

The warning dispatched by Room when the object type declared in a `https://developer.android.com/reference/androidx/room3/Query` function's multimap return type does not implement `equals()` and `hashCode()`.

### INDEX_FROM_EMBEDDED_ENTITY_IS_DROPPED

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public static final @NonNull String INDEX_FROM_EMBEDDED_ENTITY_IS_DROPPED
```

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

### INDEX_FROM_EMBEDDED_FIELD_IS_DROPPED

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public static final @NonNull String INDEX_FROM_EMBEDDED_FIELD_IS_DROPPED
```

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

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

### INDEX_FROM_PARENT_FIELD_IS_DROPPED

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public static final @NonNull String INDEX_FROM_PARENT_FIELD_IS_DROPPED
```

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

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

### INDEX_FROM_PARENT_IS_DROPPED

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public static final @NonNull String INDEX_FROM_PARENT_IS_DROPPED
```

Reported when an `https://developer.android.com/reference/androidx/room3/Entity`'s parent declares an `https://developer.android.com/reference/androidx/room3`. 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/androidx/room3/Entity#inheritSuperIndices()` to `true`.

### MISMATCHED_GETTER

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public static final @NonNull String MISMATCHED_GETTER
```

Reported when an `https://developer.android.com/reference/androidx/room3/Entity` property's type do not exactly match the getter type. For instance, in the following class:

```
@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` function 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

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public static final @NonNull String MISMATCHED_SETTER
```

Reported when an `https://developer.android.com/reference/androidx/room3/Entity` property's type do not exactly match the setter type. For instance, in the following class:

```
@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` function to write the value which doesn't accept `null`.

### MISSING_INDEX_ON_FOREIGN_KEY_CHILD

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public static final @NonNull String 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.

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

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public static final @NonNull String MISSING_INDEX_ON_JUNCTION
```

Reported when a junction entity whose column is used in a `https://developer.android.com/reference/androidx/room3/Relation` property with a `https://developer.android.com/reference/androidx/room3/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

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public static final @NonNull String MISSING_JAVA_TMP_DIR
```

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

### MISSING_SCHEMA_LOCATION

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public static final @NonNull String MISSING_SCHEMA_LOCATION
```

Reported when a `room.schemaLocation` argument is not provided into the annotation processor. You can either set `https://developer.android.com/reference/androidx/room3/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.

### NO_DATABASE_CONSTRUCTOR

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
@ExperimentalRoomApi
public static final @NonNull String NO_DATABASE_CONSTRUCTOR
```

Reported when a `https://developer.android.com/reference/androidx/room3/Database` annotated declaration is missing `https://developer.android.com/reference/androidx/room3/ConstructedBy` on non-JVM platforms. When this error is suppressed then a factory should be provided to Room's builder.

### PRIMARY_KEY_FROM_EMBEDDED_IS_DROPPED

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public static final @NonNull String PRIMARY_KEY_FROM_EMBEDDED_IS_DROPPED
```

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

### QUERY_MISMATCH

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public static final @NonNull String QUERY_MISMATCH
```

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

### RELATION_QUERY_WITHOUT_TRANSACTION

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public static final @NonNull String RELATION_QUERY_WITHOUT_TRANSACTION
```

Reported when a `https://developer.android.com/reference/androidx/room3/Query` function returns a data object that has relations but the function is not annotated with `https://developer.android.com/reference/androidx/room3/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

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public static final @NonNull String RELATION_TYPE_MISMATCH
```

Reported when a `https://developer.android.com/reference/androidx/room3/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

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public static final @NonNull String UNNECESSARY_NULLABILITY_IN_DAO_RETURN_TYPE
```

Reported when a nullable `Collection`, `Array` or `Optional` is returned from a DAO function. 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 fields

### INSTANCE

Added in [3.0.2](https://developer.android.com/jetpack/androidx/releases/room3#3.0.2)

```
public static @NonNull RoomWarnings INSTANCE
```