Skip to content

Commit a758a0e

Browse files
ToOne: update get, set and set ID methods, note important details
1 parent f61eb8b commit a758a0e

File tree

1 file changed

+10
-7
lines changed
  • objectbox-java/src/main/java/io/objectbox/relation

1 file changed

+10
-7
lines changed

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ public ToOne(Object sourceEntity, RelationInfo<?, TARGET> relationInfo) {
128128
}
129129

130130
/**
131-
* @return The target entity of the to-one relation.
131+
* Returns the target object or {@code null} if there is none.
132+
* <p>
133+
* {@link ToOne} uses lazy initialization, so on first access this will read the target object from the database.
132134
*/
133135
public TARGET getTarget() {
134136
return getTarget(getTargetId());
@@ -193,10 +195,11 @@ public boolean isNull() {
193195
}
194196

195197
/**
196-
* Sets or clears the target ID in the source entity. Pass 0 to clear.
198+
* Prepares to set the target of this relation to the object with the given ID. Pass {@code 0} to remove an existing
199+
* one.
197200
* <p>
198-
* Put the source entity to persist changes.
199-
* If the ID is not 0 creates a relation to the target entity with this ID, otherwise dissolves it.
201+
* To apply changes, put the object with the ToOne. For important details, see the notes about relations of
202+
* {@link Box#put(Object)}.
200203
*
201204
* @see #setTarget
202205
*/
@@ -224,10 +227,10 @@ void setAndUpdateTargetId(long targetId) {
224227
}
225228

226229
/**
227-
* Sets or clears the target entity and ID in the source entity. Pass null to clear.
230+
* Prepares to set the target object of this relation. Pass {@code null} to remove an existing one.
228231
* <p>
229-
* Put the source entity to persist changes.
230-
* If the target entity was not put yet (its ID is 0), it will be stored when the source entity is put.
232+
* To apply changes, put the object with the ToOne. For important details, see the notes about relations of
233+
* {@link Box#put(Object)}.
231234
*
232235
* @see #setTargetId
233236
*/

0 commit comments

Comments
 (0)