Skip to content

Commit fc70aec

Browse files
Merge branch 'to-one-detached' into dev
2 parents 4ee5178 + 6be50d6 commit fc70aec

File tree

1 file changed

+3
-2
lines changed
  • objectbox-java/src/main/java/io/objectbox/relation

1 file changed

+3
-2
lines changed

objectbox-java/src/main/java/io/objectbox/relation/ToOne.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,17 @@ private void ensureBoxes(TARGET target) {
112112
Field boxStoreField = ReflectionCache.getInstance().getField(entity.getClass(), "__boxStore");
113113
try {
114114
boxStore = (BoxStore) boxStoreField.get(entity);
115-
debugRelations = boxStore.isDebugRelations();
116115
if (boxStore == null) {
117116
if (target != null) {
118117
boxStoreField = ReflectionCache.getInstance().getField(target.getClass(), "__boxStore");
119118
boxStore = (BoxStore) boxStoreField.get(target);
120119
}
121120
if (boxStore == null) {
122-
throw new DbDetachedException("Cannot resolve relation for detached entities");
121+
throw new DbDetachedException("Cannot resolve relation for detached entities, " +
122+
"call box.attach(entity) beforehand.");
123123
}
124124
}
125+
debugRelations = boxStore.isDebugRelations();
125126
} catch (IllegalAccessException e) {
126127
throw new RuntimeException(e);
127128
}

0 commit comments

Comments
 (0)