Home | History | Annotate | Download | only in dao
      1 /*
      2  * Copyright 2018 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package androidx.room.integration.testapp.dao;
     18 
     19 import androidx.lifecycle.LiveData;
     20 import androidx.room.ColumnInfo;
     21 import androidx.room.Dao;
     22 import androidx.room.RawQuery;
     23 import androidx.room.integration.testapp.vo.NameAndLastName;
     24 import androidx.room.integration.testapp.vo.User;
     25 import androidx.room.integration.testapp.vo.UserAndAllPets;
     26 import androidx.room.integration.testapp.vo.UserAndPet;
     27 import androidx.sqlite.db.SupportSQLiteQuery;
     28 
     29 import java.util.Date;
     30 import java.util.List;
     31 
     32 @Dao
     33 public interface RawDao {
     34     @RawQuery
     35     UserAndAllPets getUserAndAllPets(SupportSQLiteQuery query);
     36 
     37     @RawQuery(observedEntities = UserAndAllPets.class)
     38     LiveData<UserAndAllPets> getUserAndAllPetsObservable(SupportSQLiteQuery query);
     39 
     40     @RawQuery
     41     User getUser(SupportSQLiteQuery query);
     42 
     43     @RawQuery
     44     UserAndPet getUserAndPet(SupportSQLiteQuery query);
     45 
     46     @RawQuery
     47     NameAndLastName getUserNameAndLastName(SupportSQLiteQuery query);
     48 
     49     @RawQuery(observedEntities = User.class)
     50     NameAndLastName getUserNameAndLastNameWithObserved(SupportSQLiteQuery query);
     51 
     52     @RawQuery
     53     int count(SupportSQLiteQuery query);
     54 
     55     @RawQuery
     56     List<User> getUserList(SupportSQLiteQuery query);
     57 
     58     @RawQuery
     59     List<UserAndPet> getUserAndPetList(SupportSQLiteQuery query);
     60 
     61     @RawQuery(observedEntities = UserAndPet.class)
     62     LiveData<List<UserAndPet>> getUserAndPetListObservable(SupportSQLiteQuery query);
     63 
     64     @RawQuery(observedEntities = User.class)
     65     LiveData<User> getUserLiveData(SupportSQLiteQuery query);
     66 
     67     @RawQuery
     68     UserNameAndBirthday getUserAndBirthday(SupportSQLiteQuery query);
     69 
     70     class UserNameAndBirthday {
     71         @ColumnInfo(name = "mName")
     72         public final String name;
     73         @ColumnInfo(name = "mBirthday")
     74         public final Date birthday;
     75 
     76         public UserNameAndBirthday(String name, Date birthday) {
     77             this.name = name;
     78             this.birthday = birthday;
     79         }
     80     }
     81 }
     82