- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我不明白为什么 for 循环会破坏我的应用程序。我知道这是一个简单的问题,但我已经盯着这段代码看了好几个小时试图弄明白。我相当确定 build.gradle 中的所有依赖项都是正确的。如果您需要更多信息,请与我们联系。谢谢你。
//应用类
package edu.uncw.seahawktours;
import android.app.Application;
import java.util.ArrayList;
import java.util.List;
import io.objectbox.Box;
import io.objectbox.BoxStore;
public class App extends Application {
private BoxStore boxStore;
@Override
public void onCreate() {
super.onCreate();
// Initialize the main data access object
boxStore = MyObjectBox.builder().androidContext(App.this).build();
// Get the wrapper (Box) for the Book table that lets us store Book objects
Box<Building> buildingBox = boxStore.boxFor(Building.class);
// Initialize with some data
if (buildingBox.count() == 0) {
List<Building> initialBooks = new ArrayList<>();
initialBooks.add(new Building("CIS", "https://library.uncw.edu/web/collections/archives/bnl/cis.html", R.drawable.cis));
initialBooks.add(new Building("Depaolo Hall", "https://library.uncw.edu/web/collections/archives/bnl/6.html", R.drawable.depaolo));
initialBooks.add(new Building("Trask Coliseum", "https://library.uncw.edu/web/collections/archives/bnl/10.html", R.drawable.trask));
initialBooks.add(new Building("King Hall", "https://library.uncw.edu/web/collections/archives/bnl/4.html", R.drawable.kinghall2));
initialBooks.add(new Building("Leutze Hall", "https://library.uncw.edu/web/collections/archives/bnl/17.html", R.drawable.leutzehall));
// ObjectBox is smart enough to handle CRUD on Collections of entities
buildingBox.put(initialBooks);
}
System.out.println(buildingBox.count());
for (Building book : buildingBox.getAll()) {
System.out.println(book.getBuildingName());
}
}
public BoxStore getBoxStore() {
return boxStore;
}
}
//建筑类
package edu.uncw.seahawktours;
import io.objectbox.annotation.Entity;
import io.objectbox.annotation.Id;
@Entity
public class Building {
@Id public long id;
private String buildingName;
private String description;
private String url;
private int imageID;
public Building(String name, String url ,int buildingPictureID){
this.buildingName = name;
this.url = url;
this.imageID = buildingPictureID;
}
public long getId() {
return id;
}
public String getDescription() {
return description;
}
public String getBuildingName() {
return buildingName;
}
public String getUrl() {
return url;
}
public int getImageID() {
return imageID;
}
public void setId(long id) {
this.id = id;
}
public void setBuildingName(String buildingName) {
this.buildingName = buildingName;
}
public void setDescription(String description) {
this.description = description;
}
public void setUrl(String url) {
this.url = url;
}
public void setImageID(int imageID) {
this.imageID = imageID;
}
@Override
public String toString() {
return this.buildingName;
}
}
//项目构建.Gradle
// Top-level build file where you can add configuration options common to
all sub-projects/modules.
buildscript {
ext.objectboxVersion = '2.2.0'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath "io.objectbox:objectbox-gradle-plugin:$objectboxVersion"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
//应用构建.Gradle
apply plugin: 'com.android.application'
apply plugin: 'io.objectbox'
android {
compileSdkVersion 28
defaultConfig {
applicationId "edu.uncw.seahawktours"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
}
最佳答案
我的回答很糟糕,但 ObjectBox 只适用于“平面”数据结构。关系实现很糟糕,和 RealmDb 一样糟糕。为什么我们不能嵌入对象,为什么一切都是关系?有一个更慢的选择,Couchbase Mobile。它几乎没有被提及,但它更像是用于移动设备的 MongoDb。我以前尝试过,但不喜欢它——我仍然不喜欢它,但我不必日复一日地寻找文档来让它工作。您只需保存您的数据结构。它不像 ObjectBox 那样类型安全(很糟糕)。似乎所有产品在不同层面上都很糟糕。
考虑一下:
ObjectBox 是平面结构和性能的最佳选择,但与服务器响应的集成很糟糕(您必须为简单的事情编写太多样板,例如更新 TooMany 关联 - ToOne,并且文档很糟糕Kotlin 和 Java 相似)
RealmDb 存在严重的多线程问题,比 ObjectBox 慢,但比 Couchbase Mobile 快得多。
Couchbase Mobile 的性能很糟糕,但您可以在从服务器接收到服务器结构时存储它们。如果 Couchbase Mobile 修复了它们的查询/插入性能,它会粉碎其他的,因为它会根据需要存储您的对象结构(例如 MAP)
我知道这无济于事,请否决我,但我花了一段时间尝试所有这些,但仍然没有找到基于离线存储的应用程序的明确路径。
关于Android ObjectBox.getAll() 返回 null,即使 objectBox.count 为 5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53567196/
我将 Angular 更新到版本 1.6.4。所以我必须将 .success 和 .error 更新为 .then 现在我收到以下错误: TypeError: .getAll(...).then is
对于像这样的简单域类: class Color { String name; } 为什么getAll()不起作用? @TestFor(MyColorService) @TestMixin(Do
我正在尝试使用泛型修改我的代码以避免所有重复的代码。 我有一个 DBBaseClass 类,它将由其他一些类扩展。我正在尝试创建一个 getAll 方法,该方法返回存储在数据库中的子类的所有对象。
我得到 RqlRuntimeError: Expected type TABLE_SLICE but found SELECTION: 链接 getAll 和 between 方法时出现错误。 r.d
我正在尝试将服务 worker 实现到我的应用程序中,我已经在 Chrome、Firefox 和 Safari 中成功做到了这一点,但在 IE 中还没有完全做到。到目前为止,我能够创建一个对象存储并向
亲爱的, 我只是想知道是否可以创建一个以 SQL 查询作为参数并继续处理请求的函数。考虑两个函数: async addExpense(req, res){ const addExpense =
我试图更新数据库上的一行,并注意到一旦更新了该行,getAll就会停止正常工作。所有已更新的记录开始从getAll的结果中丢失。 例如,假设您有一个产品列表[product1,product2,pro
这是使用 Xodus API 限制实体查询的方法: final EntityIterable allUsers = txn.getAll(storeName).skip(skip).take(limi
我想做一个项目来学习Java ee。我计划建立一个票务管理系统。所以我创建了一个 mysql 数据库、实体类、访问类、ejb 类,最后是 WService 类。对于单个 Seat 和 Customer
我正在做一个 java 应用程序。 到目前为止,这是我的文件: 人机界面。 有一个 setName(String aName) 方法 PersonImpl 人机界面的实现。 个人工厂接口(interf
IDBObjectStore有一个方法 getAll() . 但是,TypeScript 报告没有这样的方法。 lib.d.ts 中的相关部分是: interface IDBObjectStore {
我正在尝试使用 ngrx-data-lab作为我的项目的示例。 这是 stackblitz我使用的项目。 我不能使用我正在使用的服务器的实际 url。该网址属于我的公司。但实际情况是服务器将随机生成的
使用带有 4 个 Analytics 标记的 Google 跟踪代码管理器:3 个标记在“页面查看”上触发,而 1 个标记在“JavaScript 错误”上触发。 标签本身工作正常:如果 uncaug
在数据访问层中使用如下方法很常见: Tuple> GetAllWithFilter(int? page, string folderName, string title, string fil
我正在开发一个简单的 chrome 扩展程序,只需单击一下即可删除域中的所有 cookie,但由于某种原因,它无法正常工作。当我尝试从域中获取所有 cookie 时,它返回一个空数组。我究竟做错了
Angular 4 使用 get 和 getAll 方法添加了对 paramMap 的支持: 我能理解这段产生“id”值的代码 route.paramMap.subscribe( param
我在 Java 中使用 Ignite v2。下面是我的点燃节点配置。 CacheConfiguration cacheCfg = new CacheConfiguration(); c
我想为 google chrome/chromium 编写一个扩展(一个 session 管理器,它比画廊中已有的具有更多的功能和视觉效果)。 但是我无法让下面的代码工作: function list
我正在使用 Guava LoadingCache 将所有元素一次批量加载到我的急切缓存中。但是执行loadAll我提供的方法实际上并不需要 Iterable keys 参数,因为我的 DAO 也不排除
我正在使用 getAll()从数据库中获取所有项目的方法。 db.transaction('history', 'readonly').objectStore('history').getAll().
我是一名优秀的程序员,十分优秀!