Skip to content

Commit 02c784c

Browse files
Merge branch 'v2.4.1'
2 parents 2c16452 + 0e1496f commit 02c784c

File tree

7 files changed

+57
-25
lines changed

7 files changed

+57
-25
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
ObjectBox is a superfast object-oriented database with strong relation support.
55
ObjectBox is embedded into your Android, Linux, macOS, or Windows app.
66

7-
**Latest version: [2.4.0 (2019/10/15)](https://objectbox.io/changelog)**
7+
**Latest version: [2.4.1 (2019/10/29)](https://objectbox.io/changelog)**
88

99
Demo code using ObjectBox:
1010

@@ -30,7 +30,7 @@ Add this to your root build.gradle (project level):
3030

3131
```groovy
3232
buildscript {
33-
ext.objectboxVersion = '2.4.0'
33+
ext.objectboxVersion = '2.4.1'
3434
dependencies {
3535
classpath "io.objectbox:objectbox-gradle-plugin:$objectboxVersion"
3636
}

build.gradle

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ buildscript {
66
// version post fix: '-<value>' or '' if not defined; e.g. used by CI to pass in branch name
77
def versionPostFixValue = project.findProperty('versionPostFix')
88
def versionPostFix = versionPostFixValue ? "-$versionPostFixValue" : ''
9-
// ob_version = "2.4.0$versionPostFix-SNAPSHOT"
10-
ob_version = "2.4.0"
9+
// ob_version = "2.4.1$versionPostFix-SNAPSHOT"
10+
ob_version = "2.4.1"
1111
println "ObjectBox Java version $ob_version"
1212

1313
ob_expected_version = project.hasProperty('expectedVersion') ? project.property('expectedVersion') : 'UNDEFINED'
1414

1515
// Core version for tests
1616
// Be careful to diverge here; easy to forget and hard to find JNI problems
17-
// ob_native_version = "2.4.0-dev-SNAPSHOT"
18-
ob_native_version = "2.4.0"
17+
// ob_native_version = "2.4.1-dev-SNAPSHOT"
18+
ob_native_version = "2.4.1"
1919

2020
def osName = System.getProperty("os.name").toLowerCase()
2121
objectboxPlatform = osName.contains('linux') ? 'linux'

objectbox-java-api/src/main/java/io/objectbox/annotation/Id.java

+9-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
import 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)
@@ -35,8 +39,10 @@
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
}

objectbox-java-api/src/main/java/io/objectbox/annotation/Index.java

+10-5
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,20 @@
2121
import java.lang.annotation.RetentionPolicy;
2222
import 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)
3335
public @interface Index {
36+
/**
37+
* Sets the {@link IndexType}, defaults to {@link IndexType#DEFAULT}.
38+
*/
3439
IndexType type() default IndexType.DEFAULT;
3540
}

objectbox-java-api/src/main/java/io/objectbox/annotation/IndexType.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,22 @@
1717
package 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
*/
2426
public 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

objectbox-java-api/src/main/java/io/objectbox/annotation/Unique.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
import 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)

objectbox-java/src/main/java/io/objectbox/BoxStore.java

+21-2
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ public class BoxStore implements Closeable {
6464
@Nullable public static Object relinker;
6565

6666
/** Change so ReLinker will update native library when using workaround loading. */
67-
public static final String JNI_VERSION = "2.4.0";
67+
public static final String JNI_VERSION = "2.4.1";
6868

69-
private static final String VERSION = "2.4.0-2019-10-03";
69+
private static final String VERSION = "2.4.1-2019-10-29";
7070
private static BoxStore defaultStore;
7171

7272
/** Currently used DB dirs with values from {@link #getCanonicalPath(File)}. */
@@ -999,4 +999,23 @@ long panicModeRemoveAllObjects(int entityId) {
999999
return nativePanicModeRemoveAllObjects(handle, entityId);
10001000
}
10011001

1002+
/**
1003+
* If you want to use the same ObjectBox store using the C API, e.g. via JNI, this gives the required pointer,
1004+
* which you have to pass on to obx_store_wrap().
1005+
* The procedure is like this:<br>
1006+
* 1) you create a BoxStore on the Java side<br>
1007+
* 2) you call this method to get the native store pointer<br>
1008+
* 3) you pass the native store pointer to your native code (e.g. via JNI)<br>
1009+
* 4) your native code calls obx_store_wrap() with the native store pointer to get a OBX_store pointer<br>
1010+
* 5) Using the OBX_store pointer, you can use the C API.
1011+
*
1012+
* Note: Once you {@link #close()} this BoxStore, do not use it from the C API.
1013+
*/
1014+
public long getNativeStore() {
1015+
if (closed) {
1016+
throw new IllegalStateException("Store must still be open");
1017+
}
1018+
return handle;
1019+
}
1020+
10021021
}

0 commit comments

Comments
 (0)