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 11/*
2- * Copyright 2017-2019 ObjectBox Ltd. All rights reserved.
2+ * Copyright 2017-2025 ObjectBox Ltd. All rights reserved.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
3030
3131import io .objectbox .annotation .Backlink ;
3232import io .objectbox .annotation .Id ;
33- import io .objectbox .annotation .apihint .Beta ;
3433import io .objectbox .annotation .apihint .Experimental ;
3534import io .objectbox .annotation .apihint .Internal ;
3635import io .objectbox .exception .DbException ;
@@ -642,7 +641,14 @@ public synchronized EntityInfo<T> getEntityInfo() {
642641 return entityInfo ;
643642 }
644643
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+ */
646652 public void attach (T entity ) {
647653 if (boxStoreField == null ) {
648654 try {
Original file line number Diff line number Diff line change 11/*
2- * Copyright 2017 ObjectBox Ltd. All rights reserved.
2+ * Copyright 2017-2025 ObjectBox Ltd. All rights reserved.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
1616
1717package io .objectbox .exception ;
1818
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+ */
1932public class DbDetachedException extends DbException {
2033
2134 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." );
2436 }
2537
2638 public DbDetachedException (String message ) {
You can’t perform that action at this time.
0 commit comments