名前が紛らわしすぎたので*Entityにリネームした

This commit is contained in:
ろむねこ 2023-12-14 10:50:33 +09:00
parent c12319e103
commit 4dc68854d3
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168
8 changed files with 48 additions and 52 deletions

View File

@ -8,10 +8,6 @@ import one.nem.lacerta.data.Document;
import one.nem.lacerta.model.document.DocumentMeta;
import one.nem.lacerta.model.document.DocumentDetail;
import one.nem.lacerta.model.document.path.DocumentPath;
import one.nem.lacerta.model.document.tag.DocumentTag;
import one.nem.lacerta.source.database.entity.Document;
import one.nem.lacerta.source.database.LacertaDatabase;

View File

@ -4,16 +4,16 @@ import androidx.room.Database;
import androidx.room.RoomDatabase;
// Entities
import one.nem.lacerta.source.database.entity.Tag;
import one.nem.lacerta.source.database.entity.Document;
import one.nem.lacerta.source.database.entity.Library;
import one.nem.lacerta.source.database.entity.TagEntity;
import one.nem.lacerta.source.database.entity.DocumentEntity;
import one.nem.lacerta.source.database.entity.LibraryEntity;
// Daos
import one.nem.lacerta.source.database.dao.TagDao;
import one.nem.lacerta.source.database.dao.DocumentDao;
import one.nem.lacerta.source.database.dao.LibraryDao;
@Database(entities = {Tag.class, Document.class, Library.class}, version = 1)
@Database(entities = {TagEntity.class, DocumentEntity.class, LibraryEntity.class}, version = 1)
public abstract class LacertaDatabase extends RoomDatabase {
public abstract TagDao tagDao();
public abstract DocumentDao documentDao();

View File

@ -8,7 +8,7 @@ import androidx.room.Update;
import java.util.List;
import one.nem.lacerta.source.database.entity.Document;
import one.nem.lacerta.source.database.entity.DocumentEntity;
@Dao
@ -16,46 +16,46 @@ public interface DocumentDao {
// Select
@Query("SELECT * FROM document WHERE id = :id")
Document findById(String id);
@Query("SELECT * FROM DocumentEntity WHERE id = :id")
DocumentEntity findById(String id);
@Query("SELECT * FROM document")
List<Document> findAll();
@Query("SELECT * FROM DocumentEntity")
List<DocumentEntity> findAll();
@Query("SELECT * FROM document WHERE id IN (:ids)")
List<Document> findByIds(List<String> ids);
@Query("SELECT * FROM DocumentEntity WHERE id IN (:ids)")
List<DocumentEntity> findByIds(List<String> ids);
// Insert
@Insert
void insert(Document document);
void insert(DocumentEntity document);
@Insert
void insertAll(Document... documents);
void insertAll(DocumentEntity... documents);
@Insert
void insertAll(List<Document> documents);
void insertAll(List<DocumentEntity> documents);
// Update
@Update
void update(Document document);
void update(DocumentEntity document);
@Update
void updateAll(Document... documents);
void updateAll(DocumentEntity... documents);
@Update
void updateAll(List<Document> documents);
void updateAll(List<DocumentEntity> documents);
// Delete
@Delete
void delete(Document document);
void delete(DocumentEntity document);
@Delete
void deleteAll(Document... documents);
void deleteAll(DocumentEntity... documents);
@Delete
void deleteAll(List<Document> documents);
void deleteAll(List<DocumentEntity> documents);
@Query("DELETE FROM document WHERE id = :id")
@Query("DELETE FROM DocumentEntity WHERE id = :id")
void deleteById(String id);
}

View File

@ -5,19 +5,19 @@ import androidx.room.Query;
import java.util.List;
import one.nem.lacerta.source.database.entity.Library;
import one.nem.lacerta.source.database.entity.LibraryEntity;
@Dao
public interface LibraryDao {
@Query("SELECT * FROM library WHERE id = :id")
Library findById(String id);
@Query("SELECT * FROM LibraryEntity WHERE id = :id")
LibraryEntity findById(String id);
@Query("SELECT * FROM library")
List<Library> findAll();
@Query("SELECT * FROM LibraryEntity")
List<LibraryEntity> findAll();
@Query("SELECT * FROM library WHERE id IN (:ids)")
List<Library> findByIds(List<String> ids);
@Query("SELECT * FROM LibraryEntity WHERE id IN (:ids)")
List<LibraryEntity> findByIds(List<String> ids);
// WIP
// TODO-rca: Insert, Update, Delete

View File

@ -8,52 +8,52 @@ import androidx.room.Update;
import java.util.List;
import one.nem.lacerta.source.database.entity.Tag;
import one.nem.lacerta.source.database.entity.TagEntity;
@Dao
public interface TagDao {
// Select
@Query("SELECT * FROM tag WHERE id = :id")
Tag findById(String id);
@Query("SELECT * FROM TagEntity WHERE id = :id")
TagEntity findById(String id);
@Query("SELECT * FROM tag")
List<Tag> findAll();
@Query("SELECT * FROM TagEntity")
List<TagEntity> findAll();
@Query("SELECT * FROM tag WHERE id IN (:ids)")
List<Tag> findByIds(List<String> ids);
@Query("SELECT * FROM TagEntity WHERE id IN (:ids)")
List<TagEntity> findByIds(List<String> ids);
// Insert
@Insert
void insert(Tag tag);
void insert(TagEntity tag);
@Insert
void insertAll(Tag... tags);
void insertAll(TagEntity... tags);
@Insert
void insertAll(List<Tag> tags);
void insertAll(List<TagEntity> tags);
// Update
@Update
void update(Tag tag);
void update(TagEntity tag);
@Update
void updateAll(Tag... tags);
void updateAll(TagEntity... tags);
@Update
void updateAll(List<Tag> tags);
void updateAll(List<TagEntity> tags);
// Delete
@Delete
void delete(Tag tag);
void delete(TagEntity tag);
@Delete
void deleteAll(Tag... tags);
void deleteAll(TagEntity... tags);
@Delete
void deleteAll(List<Tag> tags);
void deleteAll(List<TagEntity> tags);
@Query("DELETE FROM tag WHERE id = :id")
@Query("DELETE FROM TagEntity WHERE id = :id")
void deleteById(String id);
}

View File

@ -12,7 +12,7 @@ import java.util.Date;
@Entity(tableName = "document")
@TypeConverters(DateTypeConverter.class)
public class Document {
public class DocumentEntity {
@PrimaryKey
@ColumnInfo(name = "id")
@NonNull

View File

@ -6,7 +6,7 @@ import androidx.room.Entity;
import androidx.room.PrimaryKey;
@Entity(tableName = "library")
public class Library {
public class LibraryEntity {
@PrimaryKey
@ColumnInfo(name = "id")

View File

@ -6,7 +6,7 @@ import androidx.room.Entity;
import androidx.room.PrimaryKey;
@Entity(tableName = "tag")
public class Tag {
public class TagEntity {
@PrimaryKey
@ColumnInfo(name = "id")