Android Objectbox删除实体并删除ToOne<&燃气轮机;在另一个实体中链接到它。应用程序现在仅在进行更改时在第一个构建变体上工作

Android Objectbox删除实体并删除ToOne<&燃气轮机;在另一个实体中链接到它。应用程序现在仅在进行更改时在第一个构建变体上工作,android,objectbox,Android,Objectbox,在我的应用程序中,我有两个实体CardEntity和DeckCard。我想完全删除CardEntity,并更新DeckCard以不再引用它 public class CardEntity extends BaseEntity { private char letter; private int bonus; public CardEntity() { } public CardEntity(char letter) { this(le

在我的应用程序中,我有两个实体
CardEntity
DeckCard
。我想完全删除
CardEntity
,并更新
DeckCard
以不再引用它

public class CardEntity extends BaseEntity {

    private char letter;
    private int bonus;

    public CardEntity() {
    }

    public CardEntity(char letter) {
        this(letter, 0);
    }

    public CardEntity(char letter, int bonus) {
        this.letter = letter;
        this.bonus = bonus;
    }

    public char getLetter() {
        return letter;
    }

    public int getBonus() {
        return bonus;
    }

    public void setLetter(char letter) {
        this.letter = letter;
    }

    public void setBonus(int bonus) {
        this.bonus = bonus;
    }
}

正如预期的那样,这很好。然而,它只适用于我当时在Android Studio中选择的任何构建变体。我所说的selected是指下一次应用程序运行并且更新
objectbox models/default.json
文件时

若我使用的是调试构建变量,那个么它在发布构建变量上就不起作用,反之亦然

我非常确定,当我重命名某个东西或更改它的类型时,我只需要使用
Uid
命令。在这个例子中,我两个都不做,我删除并创建了一些新的东西

下面是objectbox创建的默认.json`文件更改的git差异

index 93401bf..85ef145 100644
--- a/core/objectbox-models/default.json
+++ b/core/objectbox-models/default.json
@@ -56,28 +56,8 @@
       "relations": []
     },
     {
-      "id": "3:6780553593369094070",
-      "lastPropertyId": "3:5487168684448628175",
-      "name": "CardEntity",
-      "properties": [
-        {
-          "id": "1:6704627251462640845",
-          "name": "id"
-        },
-        {
-          "id": "2:3991826258957414994",
-          "name": "letter"
-        },
-        {
-          "id": "3:5487168684448628175",
-          "name": "bonus"
-        }
-      ],
-      "relations": []
-    },
-    {
       "id": "5:5013495804474067017",
-      "lastPropertyId": "3:4210233198992719300",
+      "lastPropertyId": "5:3189718515123354120",
       "name": "DeckCard",
       "properties": [
         {
@@ -89,16 +69,19 @@
           "name": "position"
         },
         {
-          "id": "3:4210233198992719300",
-          "indexId": "1:4945633363495390935",
-          "name": "cardId"
+          "id": "4:256499331611759584",
+          "name": "letter"
+        },
+        {
+          "id": "5:3189718515123354120",
+          "name": "bonus"
         }
       ],
       "relations": []
     },
     {
       "id": "6:5212062744213571670",
-      "lastPropertyId": "2:2822761128112662405",
+      "lastPropertyId": "3:3928832151786754926",
       "name": "DeckEntity",
       "properties": [
         {
@@ -107,8 +90,11 @@
         },
         {
           "id": "2:2822761128112662405",
-          "indexId": "3:1461174128207782541",
-          "name": "date"
+          "name": "value"
+        },
+        {
+          "id": "3:3928832151786754926",
+          "name": "deckType"
         }
       ],
       "relations": [
@@ -362,10 +348,13 @@
   "retiredEntityUids": [
     4969708316960283445,
     5055976600245924974,
-    4563426853935656920
+    4563426853935656920,
+    6780553593369094070
   ],
   "retiredIndexUids": [
-    1897667010269871647
+    1897667010269871647,
+    1461174128207782541,
+    4945633363495390935
   ],
   "retiredPropertyUids": [
     5471484579006047884,
@@ -378,7 +367,11 @@
     6425939462895623468,
     6798215028749536251,
     3730774925178609899,
-    808949111095751851
+    808949111095751851,
+    4210233198992719300,
+    6704627251462640845,
+    3991826258957414994,
+    5487168684448628175
   ],
   "retiredRelationUids": [
     785742710602534748,

更新:为使问题更加清晰…

更新:观察到的行为无法在当前版本的ObjectBox(如2.5.1)中重现,而只能在旧版本(2.0.0)中重现

总结:

  • 您打算将两个实体类型的属性“合并”为一个
  • CardEntity已删除
  • DeckCard获得两个附加属性,并将ToOne删除到CardEntity

对不起,不能将两个合并为一个。完全摆脱CardEntity,而不是在DeckCard中使用它,我只想使用这两个原语。构建之间的实体类也没有区别。至于“不工作”,我会抓取一个堆栈跟踪,并在另一条评论中发布它-它从我认为是崩溃开始的地方开始,我不知道崩溃实际上在哪里结束,所以可能有很多“不工作”的后遗症,即应用程序编译、安装、启动,然后在不到1s的时间内崩溃。在任何真正提到应用程序包名称的错误日志中都没有java错误,上面的pastebin是基于对整个电话日志的搜索,但至少它提到了包。“完全摆脱CardEntity,而不是将其包含在DeckCard中,我只想使用这两个原语。”->是的。我想我们指的是同一件事。“合并”两个实体的属性。。。我会澄清。。。对于本机崩溃,我刚刚创建了一个-看起来肯定像一个bug…通过库更新确认所有问题都已修复。谢谢@Markus
public class DeckCard extends BaseEntity {

    private Integer position;
    private char letter;
    private int bonus;

    public DeckCard() {
    }

    public DeckCard(Integer position, char letter, int bonus) {
        this.position = position;
        this.letter = letter;
        this.bonus = bonus;
    }

    public Integer getPosition() {
        return position;
    }

    public void setPosition(Integer position) {
        this.position = position;
    }

    public char getLetter() {
        return letter;
    }

    public void setLetter(char letter) {
        this.letter = letter;
    }

    public int getBonus() {
        return bonus;
    }

    public void setBonus(int bonus) {
        this.bonus = bonus;
    }
}
index 93401bf..85ef145 100644
--- a/core/objectbox-models/default.json
+++ b/core/objectbox-models/default.json
@@ -56,28 +56,8 @@
       "relations": []
     },
     {
-      "id": "3:6780553593369094070",
-      "lastPropertyId": "3:5487168684448628175",
-      "name": "CardEntity",
-      "properties": [
-        {
-          "id": "1:6704627251462640845",
-          "name": "id"
-        },
-        {
-          "id": "2:3991826258957414994",
-          "name": "letter"
-        },
-        {
-          "id": "3:5487168684448628175",
-          "name": "bonus"
-        }
-      ],
-      "relations": []
-    },
-    {
       "id": "5:5013495804474067017",
-      "lastPropertyId": "3:4210233198992719300",
+      "lastPropertyId": "5:3189718515123354120",
       "name": "DeckCard",
       "properties": [
         {
@@ -89,16 +69,19 @@
           "name": "position"
         },
         {
-          "id": "3:4210233198992719300",
-          "indexId": "1:4945633363495390935",
-          "name": "cardId"
+          "id": "4:256499331611759584",
+          "name": "letter"
+        },
+        {
+          "id": "5:3189718515123354120",
+          "name": "bonus"
         }
       ],
       "relations": []
     },
     {
       "id": "6:5212062744213571670",
-      "lastPropertyId": "2:2822761128112662405",
+      "lastPropertyId": "3:3928832151786754926",
       "name": "DeckEntity",
       "properties": [
         {
@@ -107,8 +90,11 @@
         },
         {
           "id": "2:2822761128112662405",
-          "indexId": "3:1461174128207782541",
-          "name": "date"
+          "name": "value"
+        },
+        {
+          "id": "3:3928832151786754926",
+          "name": "deckType"
         }
       ],
       "relations": [
@@ -362,10 +348,13 @@
   "retiredEntityUids": [
     4969708316960283445,
     5055976600245924974,
-    4563426853935656920
+    4563426853935656920,
+    6780553593369094070
   ],
   "retiredIndexUids": [
-    1897667010269871647
+    1897667010269871647,
+    1461174128207782541,
+    4945633363495390935
   ],
   "retiredPropertyUids": [
     5471484579006047884,
@@ -378,7 +367,11 @@
     6425939462895623468,
     6798215028749536251,
     3730774925178609899,
-    808949111095751851
+    808949111095751851,
+    4210233198992719300,
+    6704627251462640845,
+    3991826258957414994,
+    5487168684448628175
   ],
   "retiredRelationUids": [
     785742710602534748,