File tree Expand file tree Collapse file tree 4 files changed +30
-17
lines changed
objectbox-java-api/src/main/java/io/objectbox/annotation Expand file tree Collapse file tree 4 files changed +30
-17
lines changed Original file line number Diff line number Diff line change 2222import java .lang .annotation .Target ;
2323
2424/**
25- * Marks field is the primary key of the entity's table
25+ * Marks the ID property of an {@link Entity @Entity}.
26+ * The property must be of type long (or Long in Kotlin) and have not-private visibility
27+ * (or a not-private getter and setter method).
28+ * <p>
29+ * ID properties are unique and indexed by default.
2630 */
2731@ Retention (RetentionPolicy .CLASS )
2832@ Target (ElementType .FIELD )
3539// boolean monotonic() default false;
3640
3741 /**
38- * Allows IDs to be assigned by the developer. This may make sense for using IDs originating somewhere else, e.g.
39- * from the server.
42+ * Allows IDs of new entities to be assigned manually.
43+ * Warning: This has side effects, check the online documentation on self-assigned object IDs for details.
44+ * <p>
45+ * This may allow re-use of IDs assigned elsewhere, e.g. by a server.
4046 */
4147 boolean assignable () default false ;
4248}
Original file line number Diff line number Diff line change 2121import java .lang .annotation .RetentionPolicy ;
2222import java .lang .annotation .Target ;
2323
24- import io .objectbox .annotation .apihint .Internal ;
25-
2624/**
27- * Specifies that the property should be indexed, which is highly recommended if you do queries using this property.
28- *
29- * To fine tune indexing you can specify {@link IndexType} if necessary.
25+ * Specifies that the property should be indexed.
26+ * <p>
27+ * It is highly recommended to index properties that are used in a query to improve query performance.
28+ * <p>
29+ * To fine tune indexing of a property you can override the default index {@link #type()}.
30+ * <p>
31+ * Note: indexes are currently not supported for byte array, float or double properties.
3032 */
3133@ Retention (RetentionPolicy .CLASS )
3234@ Target (ElementType .FIELD )
3335public @interface Index {
36+ /**
37+ * Sets the {@link IndexType}, defaults to {@link IndexType#DEFAULT}.
38+ */
3439 IndexType type () default IndexType .DEFAULT ;
3540}
Original file line number Diff line number Diff line change 1717package io .objectbox .annotation ;
1818
1919/**
20- * ObjectBox offers three index types, from which it chooses from with a reasonable default (see {@link #DEFAULT}).
20+ * ObjectBox offers a value and two hash index types, from which it chooses a reasonable default (see {@link #DEFAULT}).
2121 * <p>
2222 * For some queries/use cases it might make sense to override the default choice for optimization purposes.
23+ * <p>
24+ * Note: hash indexes are currently only supported for string properties.
2325 */
2426public enum IndexType {
2527 /**
2628 * Use the default index type depending on the property type:
27- * {@link #VALUE} for scalars and {@link #HASH} for Strings and byte arrays .
29+ * {@link #VALUE} for scalars and {@link #HASH} for Strings.
2830 */
2931 DEFAULT ,
3032
3133 /**
3234 * Use the property value to build the index.
33- * For Strings and byte arrays this may occupy more space than the default setting.
35+ * For Strings this may occupy more space than the default setting.
3436 */
3537 VALUE ,
3638
Original file line number Diff line number Diff line change 2222import java .lang .annotation .Target ;
2323
2424/**
25- * Marks values of a property to be unique .
26- * The property will be indexed behind the scenes, just like using @{@link Index}.
27- * Thus you do not need to put an extra @{@link Index} on the property, unless you want to configure the index with
28- * additional parameters.
29- *
30- * Trying to put object with offending values will result in a UniqueViolationException .
25+ * Enforces that the value of a property is unique among all objects in a box before an object can be put .
26+ * <p>
27+ * Trying to put an object with offending values will result in a UniqueViolationException.
28+ * <p>
29+ * Unique properties are based on an {@link Index @Index}, so the same restrictions apply.
30+ * It is supported to explicitly add the {@link Index @Index} annotation to configure the index .
3131 */
3232@ Retention (RetentionPolicy .CLASS )
3333@ Target (ElementType .FIELD )
You can’t perform that action at this time.
0 commit comments