public abstract @interface DatabaseView
implements Annotation

Marks a class as an SQLite view.

The value of the annotation is a SELECT query used when the view is created.

The class will behave like normal POJOs when it is used in Dao. You can SELECT from DatabaseView like Entity, but you can not INSERT, DELETE or UPDATE DatabaseView. You can use ColumnInfo and Embedded inside.


 @DatabaseView("SELECT id, last_name FROM User")
 public class UserSummary {
     public long id;
     @ColumnInfo(name = "last_name")
     public String lastName;

Views have to be registered to a RoomDatabase via Database.views(). Room will automatically create a backing SQLite view.


Public methods

String value()

The SELECT query.

String viewName()

The view name in the SQLite database.

Inherited methods

Public methods


public String value ()

The SELECT query.

String The SELECT query.


public String viewName ()

The view name in the SQLite database. If not set, it defaults to the class name.

String The SQLite view name.