Skip to content

Commit 550da3f

Browse files
committed
add BoxStore.getNativeStore()
1 parent 9fd1e8b commit 550da3f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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)