Java and Android Database - fast and lightweight without any ORM
ToOne
instead of ToOne<Entity>
).AndroidObjectBrowser
, use Admin
instead. AndroidObjectBrowser
will be removed in a future release.This release only contains bug fixes for the Android library when used with ObjectBox for Dart/Flutter.
This release only contains bug fixes.
localhost:8090
and localhost:8091
).Read the blog post with more details and code examples for the new flex properties and query conditions.
3.0.0
, it is now possible to add a property using Object
in Java or Any?
in Kotlin. These "flex properties" now allow to store values of various types like integers, floating point values, strings and byte arrays. Or lists and maps (using string keys) of those. Some limitations apply, see the FlexObjectConverter
class documentation for details.
@Entity
data class Customer(
@Id var id: Long = 0,
var tag: Any? = null
)
val customerStrTag = Customer(tag = "string-tag")
val customerIntTag = Customer(tag = 1234)
box.put(customerStrTag, customerIntTag)
containsElement
query condition now matches keys of string map properties. It also matches string or integer elements of a Flex list.containsKeyValue
query condition to match key/value combinations of string map and Flex map properties containing strings and integers. Also added matching Query.setParameters
overload.
val customer = Customer(
properties = mutableMapOf("premium" to "tier-1")
)
box.put(customer)
// Query for any customers that have a premium key in their properties map
val queryPremiumAll = box.query(
Customer_.properties.containsElement("premium")
).build()
// Match only customers with specific key and value map entry
val queryPremiumTier1 = box.query(
Customer_.properties.containsKeyValue("premium", "tier-1")
).build()
SuppressFBWarnings
annotation. #1011BoxStore.awaitCallInTx
suspend function which wraps BoxStore.callInTx
.application
plugin.See the 3.0.0 release notes for a list of important changes.
Note: this version contains a bug that prevents usage with Android Java only projects. Use 3.0.1
instead.
// equal AND (less OR oneOf)
val query = box.query(
User_.firstName equal "Joe"
and (User_.age less 12
or (User_.stamp oneOf longArrayOf(1012))))
.order(User_.age)
.build()
StringOrder
for which one to choose (typically StringOrder.CASE_INSENSITIVE
).
// Replace String conditions like
query().equal(User_.firstName, "Joe")
// With the one accepting a StringOrder
query().equal(User_.firstName, "Joe", StringOrder.CASE_INSENSITIVE)
@Entity
class is missing a no-arg (easy to add) or all properties (best for performance) constructor. #900
Example for an all properties constructor:
@Entity
public class Order {
@Id
private long id;
private ToOne<Customer> customer;
private ToMany<Order> relatedOrders;
// All properties constructor for ObjectBox:
// - make sure type matches exactly,
// - for ToOne add its virtual ID property instead,
// - for ToMany add no parameter.
public Order(long id, long customerId) {
this.id = id;
this.customer.setTargetId(customerId);
}
// TODO getters and setters for properties
}
@Unique(onConflict = ConflictStrategy.REPLACE)
to replace an existing Object if a conflict occurs when doing a put. #509
@Entity
data class Example(
@Id
var id: Long = 0,
@Unique(onConflict = ConflictStrategy.REPLACE)
var uniqueKey: String? = null
)
@Unsigned
to indicate that values of an integer property (e.g. Integer
and Long
in Java) should be treated as unsigned when doing queries or creating indexes.@Type
annotation:
@Type(DatabaseType.DateNano)
var timeInNanos: Long;
Flow
extension functions for BoxStore
and Query
. #990NaN
value. #984String[]
and Kotlin Array<String>
) and lists (Java List<String>
and Kotlin MutableList<String>
). Using the new containsElement("item")
condition, it is also possible to query for entities where "item" is equal to one of the elements.
@Entity
data class Example(
@Id
var id: Long = 0,
var stringArray: Array<String>? = null,
var stringMap: MutableMap<String, String>? = null
)
// matches [“first”, “second”, “third”]
box.query(Example_.stringArray.containsElement(“second”)).build()
Map<String, String>
or Kotlin MutableMap<String, String>
). Stored internally as a byte array using FlexBuffers.This is the first release available on the Central repository (Sonatype OSSRH). Make sure to adjust your build.gradle
files accordingly:
repositories {
mavenCentral()
}
Changes:
find(offset, limit)
of Query
is more concrete on how offset and limit work.objectbox-android:2.9.0:sync
is replaced with objectbox-sync-android:2.9.1
.lessOrEqual
and greaterOrEqual
conditions for long, String, double and byte[] properties.implementation "io.objectbox:objectbox-linux-armv7:$objectboxVersion
or implementation "io.objectbox:objectbox-linux-arm64:$objectboxVersion
to your dependencies. Otherwise the setup is identical with Java Desktop Apps.ClassNotFoundException: kotlin.text.Charsets
when running processor. #946See the 2.8.0 release notes for the latest changes.
Query.findLazy()
and Query.findLazyCached()
work with LazyList
#906).@Index
and @Id
errors. #902DbExceptionListener
by accepting null values for BoxStore.setDbExceptionListener(listener)
.