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 22
22
import java .lang .annotation .Target ;
23
23
24
24
/**
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.
26
30
*/
27
31
@ Retention (RetentionPolicy .CLASS )
28
32
@ Target (ElementType .FIELD )
35
39
// boolean monotonic() default false;
36
40
37
41
/**
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.
40
46
*/
41
47
boolean assignable () default false ;
42
48
}
Original file line number Diff line number Diff line change 21
21
import java .lang .annotation .RetentionPolicy ;
22
22
import java .lang .annotation .Target ;
23
23
24
- import io .objectbox .annotation .apihint .Internal ;
25
-
26
24
/**
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.
30
32
*/
31
33
@ Retention (RetentionPolicy .CLASS )
32
34
@ Target (ElementType .FIELD )
33
35
public @interface Index {
36
+ /**
37
+ * Sets the {@link IndexType}, defaults to {@link IndexType#DEFAULT}.
38
+ */
34
39
IndexType type () default IndexType .DEFAULT ;
35
40
}
Original file line number Diff line number Diff line change 17
17
package io .objectbox .annotation ;
18
18
19
19
/**
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}).
21
21
* <p>
22
22
* 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.
23
25
*/
24
26
public enum IndexType {
25
27
/**
26
28
* 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.
28
30
*/
29
31
DEFAULT ,
30
32
31
33
/**
32
34
* 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.
34
36
*/
35
37
VALUE ,
36
38
Original file line number Diff line number Diff line change 22
22
import java .lang .annotation .Target ;
23
23
24
24
/**
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 .
31
31
*/
32
32
@ Retention (RetentionPolicy .CLASS )
33
33
@ Target (ElementType .FIELD )
You can’t perform that action at this time.
0 commit comments