Room系列专题

Android Jetpack之Room篇

Room Entity注解说明

Room Dao注解说明

Room Fts 虚拟表模块

Room DatabaseView 视图

Room SkipQueryVerification

Room TypeConverter 属性类型转换器

定义

将类标记为SQLite视图。

注释的值是创建视图时使用的SELECT查询

字段说明

1
2
3
4
5
6
7
8
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.CLASS)
public @interface DatabaseView {
    //
    String value() default "";
    //
    String viewName() default "";
}

例子

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
@DatabaseView(
        "SELECT id, name, release_year FROM Song " +
                "WHERE release_year >= 1990 AND release_year <= 1999")
public class SongFrom90s {

    long id;

    String name;

    @ColumnInfo(name = "release_year")
    private int releaseYear;
}

如果你喜欢我的文章,可以关注我的掘金、公众号、博客、简书或者Github!

简书: https://www.jianshu.com/u/a2591ab8eed2

GitHub: https://github.com/bugyun

Blog: https://ruoyun.vip

掘金: https://juejin.im/user/56cbef3b816dfa0059e330a8/posts

CSDN: https://blog.csdn.net/zxloveooo

欢迎关注微信公众号