1 /* 2 * Copyright (C) 2016 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 foo.bar; 18 19 import android.arch.persistence.db.SupportSQLiteStatement; 20 import android.arch.persistence.room.EntityInsertionAdapter; 21 import android.arch.persistence.room.RoomDatabase; 22 23 import java.lang.Override; 24 import java.lang.String; 25 import java.util.List; 26 import javax.annotation.Generated; 27 28 @Generated("android.arch.persistence.room.RoomProcessor") 29 public class WriterDao_Impl implements WriterDao { 30 private final RoomDatabase __db; 31 32 private final EntityInsertionAdapter __insertionAdapterOfUser; 33 34 private final EntityInsertionAdapter __insertionAdapterOfUser_1; 35 36 private final EntityInsertionAdapter __insertionAdapterOfBook; 37 38 public WriterDao_Impl(RoomDatabase __db) { 39 this.__db = __db; 40 this.__insertionAdapterOfUser = new EntityInsertionAdapter<User>(__db) { 41 @Override 42 public String createQuery() { 43 return "INSERT OR ABORT INTO `User`(`uid`,`name`,`lastName`,`ageColumn`) VALUES" 44 + " (?,?,?,?)"; 45 } 46 47 @Override 48 public void bind(SupportSQLiteStatement stmt, User value) { 49 stmt.bindLong(1, value.uid); 50 if (value.name == null) { 51 stmt.bindNull(2); 52 } else { 53 stmt.bindString(2, value.name); 54 } 55 if (value.getLastName() == null) { 56 stmt.bindNull(3); 57 } else { 58 stmt.bindString(3, value.getLastName()); 59 } 60 stmt.bindLong(4, value.age); 61 } 62 }; 63 this.__insertionAdapterOfUser_1 = new EntityInsertionAdapter<User>(__db) { 64 @Override 65 public String createQuery() { 66 return "INSERT OR REPLACE INTO `User`(`uid`,`name`,`lastName`,`ageColumn`) VALUES" 67 + " (?,?,?,?)"; 68 } 69 70 @Override 71 public void bind(SupportSQLiteStatement stmt, User value) { 72 stmt.bindLong(1, value.uid); 73 if (value.name == null) { 74 stmt.bindNull(2); 75 } else { 76 stmt.bindString(2, value.name); 77 } 78 if (value.getLastName() == null) { 79 stmt.bindNull(3); 80 } else { 81 stmt.bindString(3, value.getLastName()); 82 } 83 stmt.bindLong(4, value.age); 84 } 85 }; 86 this.__insertionAdapterOfBook = new EntityInsertionAdapter<Book>(__db) { 87 @Override 88 public String createQuery() { 89 return "INSERT OR ABORT INTO `Book`(`bookId`,`uid`) VALUES (?,?)"; 90 } 91 92 @Override 93 public void bind(SupportSQLiteStatement stmt, Book value) { 94 stmt.bindLong(1, value.bookId); 95 stmt.bindLong(2, value.uid); 96 } 97 }; 98 } 99 100 @Override 101 public void insertUser(User user) { 102 __db.beginTransaction(); 103 try { 104 __insertionAdapterOfUser.insert(user); 105 __db.setTransactionSuccessful(); 106 } finally { 107 __db.endTransaction(); 108 } 109 } 110 111 @Override 112 public void insertUsers(User user1, List<User> others) { 113 __db.beginTransaction(); 114 try { 115 __insertionAdapterOfUser.insert(user1); 116 __insertionAdapterOfUser.insert(others); 117 __db.setTransactionSuccessful(); 118 } finally { 119 __db.endTransaction(); 120 } 121 } 122 123 @Override 124 public void insertUsers(User[] users) { 125 __db.beginTransaction(); 126 try { 127 __insertionAdapterOfUser_1.insert(users); 128 __db.setTransactionSuccessful(); 129 } finally { 130 __db.endTransaction(); 131 } 132 } 133 134 @Override 135 public void insertUserAndBook(User user, Book book) { 136 __db.beginTransaction(); 137 try { 138 __insertionAdapterOfUser.insert(user); 139 __insertionAdapterOfBook.insert(book); 140 __db.setTransactionSuccessful(); 141 } finally { 142 __db.endTransaction(); 143 } 144 } 145 } 146