File tree Expand file tree Collapse file tree 2 files changed +24
-6
lines changed
objectbox-java/src/main/java/io/objectbox Expand file tree Collapse file tree 2 files changed +24
-6
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2017-2019 ObjectBox Ltd. All rights reserved.
2
+ * Copyright 2017-2025 ObjectBox Ltd. All rights reserved.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
30
30
31
31
import io .objectbox .annotation .Backlink ;
32
32
import io .objectbox .annotation .Id ;
33
- import io .objectbox .annotation .apihint .Beta ;
34
33
import io .objectbox .annotation .apihint .Experimental ;
35
34
import io .objectbox .annotation .apihint .Internal ;
36
35
import io .objectbox .exception .DbException ;
@@ -642,7 +641,14 @@ public synchronized EntityInfo<T> getEntityInfo() {
642
641
return entityInfo ;
643
642
}
644
643
645
- @ Beta
644
+ /**
645
+ * Attaches the given object to this.
646
+ * <p>
647
+ * This typically should only be used when <a
648
+ * href="https://docs.objectbox.io/advanced/object-ids#self-assigned-object-ids">manually assigning IDs</a>.
649
+ *
650
+ * @param entity The object to attach this to.
651
+ */
646
652
public void attach (T entity ) {
647
653
if (boxStoreField == null ) {
648
654
try {
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2017 ObjectBox Ltd. All rights reserved.
2
+ * Copyright 2017-2025 ObjectBox Ltd. All rights reserved.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
16
16
17
17
package io .objectbox .exception ;
18
18
19
+ /**
20
+ * This exception occurs while working with a {@link io.objectbox.relation.ToMany ToMany} or
21
+ * {@link io.objectbox.relation.ToOne ToOne} of an object and the object is not attached to a
22
+ * {@link io.objectbox.Box Box} (technically a {@link io.objectbox.BoxStore BoxStore}).
23
+ * <p>
24
+ * If your code uses <a href="https://docs.objectbox.io/advanced/object-ids#self-assigned-object-ids">manually assigned
25
+ * IDs</a> make sure it takes care of some things that ObjectBox would normally do by itself. This includes
26
+ * {@link io.objectbox.Box#attach(Object) attaching} the Box to an object before modifying a ToMany.
27
+ * <p>
28
+ * Also see the documentation about <a href="https://docs.objectbox.io/relations#updating-relations">Updating
29
+ * Relations</a> and <a href="https://docs.objectbox.io/advanced/object-ids#self-assigned-object-ids">manually assigned
30
+ * IDs</a> for details.
31
+ */
19
32
public class DbDetachedException extends DbException {
20
33
21
34
public DbDetachedException () {
22
- this ("Cannot perform this action on a detached entity. " +
23
- "Ensure it was loaded by ObjectBox, or attach it manually." );
35
+ this ("Entity must be attached to a Box." );
24
36
}
25
37
26
38
public DbDetachedException (String message ) {
You can’t perform that action at this time.
0 commit comments