GithubHelp home page GithubHelp logo

objectbox / objectbox-java Goto Github PK

View Code? Open in Web Editor NEW
4.3K 107.0 297.0 2.63 MB

Java and Android Database - fast and lightweight without any ORM

Home Page: https://objectbox.io

License: Apache License 2.0

Java 97.36% Kotlin 2.10% Shell 0.27% HTML 0.05% Groovy 0.22%
android nosql database java kotlin mobile edge sustainable sqlite embedded

objectbox-java's Introduction

Getting StartedDocumentationExample AppsIssues

Latest Release Star objectbox-java Apache 2.0 license Follow @ObjectBox_io

ObjectBox - Fast and Efficient Java Database (Android, JVM)

ObjectBox Java is a simple yet powerful database designed specifically for Java and Kotlin applications. Store and manage data effortlessly in your Android or JVM Linux, macOS or Windows app with ObjectBox. Enjoy exceptional speed, frugal resource usage, and environmentally-friendly development. 💚

Demo code

// Java
Playlist playlist = new Playlist("My Favorites");
playlist.songs.add(new Song("Lalala"));
playlist.songs.add(new Song("Lololo"));
box.put(playlist);

➡️ More details in the docs

// Kotlin
val playlist = Playlist("My Favorites")
playlist.songs.add(Song("Lalala"))
playlist.songs.add(Song("Lololo"))
box.put(playlist)

Table of Contents

Key Features

🏁 High performance: exceptional speed, outperforming alternatives like SQLite and Realm in all CRUD operations.
💚 Efficient Resource Usage: minimal CPU, power and memory consumption for maximum flexibility and sustainability.
🔗 Built-in Object Relations: built-in support for object relations, allowing you to easily establish and manage relationships between objects.
👌 Ease of use: concise API that eliminates the need for complex SQL queries, saving you time and effort during development.

Getting started

Gradle setup

For Android projects, add the ObjectBox Gradle plugin to your root build.gradle:

buildscript {
    ext.objectboxVersion = "3.8.0"
    repositories {        
        mavenCentral()    
    }
    dependencies {
        classpath("io.objectbox:objectbox-gradle-plugin:$objectboxVersion")
    }
}

And in your app's build.gradle apply the plugin:

// Using plugins syntax:
plugins {
    id("io.objectbox") // Add after other plugins.
}

// Or using the old apply syntax:
apply plugin: "io.objectbox" // Add after other plugins.

First steps

Create a data object class @Entity, for example "Playlist".

// Kotlin
@Entity data class Playlist( ... )

// Java
@Entity public class Playlist { ... }

Now build the project to let ObjectBox generate the class MyObjectBox for you.

Prepare the BoxStore object once for your app, e.g. in onCreate in your Application class:

boxStore = MyObjectBox.builder().androidContext(this).build();

Then get a Box class for the Playlist entity class:

Box<Playlist> box = boxStore.boxFor(Playlist.class);

The Box object gives you access to all major functions, like put, get, remove, and query.

For details please check the docs.

Why use ObjectBox for Java data management?

ObjectBox is a NoSQL Java database designed for local data storage on resource-restricted devices, prioritizing offline-first functionality. It is a smart and sustainable choice for local data persistence in Java and Kotlin applications. It offers efficiency, ease of use, and flexibility.

Fast but resourceful

Optimized for speed and minimal resource consumption, ObjectBox is an ideal solution for mobile devices. It has excellent performance, while also minimizing CPU, RAM, and power usage. ObjectBox outperforms SQLite and Realm across all CRUD (Create, Read, Update, Delete) operations. Check out our Performance Benchmarking App repository.

Simple but powerful

With its concise language-native API, ObjectBox simplifies development by requiring less code compared to SQLite. It operates on plain objects (POJOs) with built-in relations, eliminating the need to manage rows and columns. This approach is efficient for handling large data volumes and allows for easy model modifications.

Functionality

💐 Queries: filter data as needed, even across relations
💻 Multiplatform: supports Android and JVM on Linux (also on ARM), Windows and macOS
🌱 Scalable: handling millions of objects resource-efficiently with ease
🦮 Statically typed: compile time checks & optimizations
📃 Automatic schema migrations: no update scripts needed

And much more than just data persistence
🔄 ObjectBox Sync: keeps data in sync between devices and servers
🕒 ObjectBox TS: time series extension for time based data

Community and Support

Tell us what you think! Share your thoughts through our Anonymous Feedback Form.

At ObjectBox, we are dedicated to bringing joy and delight to app developers by providing intuitive and fun-to-code-with APIs. We genuinely want to hear from you: What do you love about ObjectBox? What could be improved? Where do you face challenges in everyday app development?

We eagerly await your comments and requests, so please feel free to reach out to us:

  • Add GitHub issues
  • Upvote important issues 👍
  • Drop us a line via @ObjectBox_io or contact[at]objectbox.io
  • ⭐ us on GitHub if you like what you see!

Thank you! Stay updated with our blog.

Other languages/bindings

ObjectBox supports multiple platforms and languages. Besides JVM based languages like Java and Kotlin, ObjectBox also offers:

License

Copyright 2017-2024 ObjectBox Ltd. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Note that this license applies to the code in this repository only. See our website on details about all licenses for ObjectBox components.

objectbox-java's People

Contributors

dependabot[bot] avatar greenrobot avatar greenrobot-team avatar ivahnenkoanna avatar ligi avatar loryruta avatar obx-vivien avatar vahid1919 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

objectbox-java's Issues

Improve error message when primary relation for backlink is missing

Im getting the following crash when im tying to access the to-many Relation:

java.lang.IllegalArgumentException: Argument condition "isRelation" not met in objectbox::Cursor *objectbox::Cursor::findBacklinkKeys(objectbox::Property *, entity_id, KeyVector &):419
                                                                                 at io.objectbox.Cursor.nativeGetBacklinkEntities(Native Method)
                                                                                 at io.objectbox.Cursor.getBacklinkEntities(Cursor.java:239)
                                                                                 at io.objectbox.Box.getBacklinkEntities(Box.java:519)

Im not getting this error on other to-many relations.

This is the auto generated method:

/**
     * To-many relationship, resolved on first access (and after reset).
     * Changes to to-many relations are not persisted, make changes to the target entity.
     */
    @Generated(hash = 586376241)
    public List<State> getStates() {
        if (states == null) {
            final BoxStore boxStore = this.__boxStore;
            if (boxStore == null) {
                throw new DbDetachedException();
            }
            Box<State> box = boxStore.boxFor(State.class);
            int targetTypeId = boxStore.getEntityTypeIdOrThrow(State.class);
            List<State> statesNew = box.getBacklinkEntities(targetTypeId, State_.deviceId, id);
            synchronized (this) {
                if (states == null) {
                    states = statesNew;
                }
            }
        }
        return states;
    }

and the State class

@Entity
public class State {

    @Id
    private long id;

    private String key;

    private String value;

    private long deviceId;
...

and the State Array in the Device class

@Relation(idProperty = "deviceId")
private List<State> states;

Polymorphic entities

Allow subclassing of entities.

Affects:

  • Box: should baseBox.get(subclassId) return a subclass entity? Probably so.
  • Queries: Querying for the base class should return all sub classes.
  • Relations: if a relation references a base class, actual objects may also be sub classes.

FAQ: Fair Benchmarks

I know greenrobot has done some fair benchmarks in the past for greendao. It'd be nice to see some benchmarks comparing ObjectBox against some of the other popular database solutions:

  • sqlite
  • sqlite compiled statement
  • realm

To-One Relations: __boxStore field missing

When I use The To - One Relations

For example:

@entity
public class Order {
@id long id;

long customerId;

@Relation Customer customer;

/** Used to resolve relations */
@Internal
@Generated(hash = 1307364262)
transient BoxStore __boxStore;

@Generated(hash = 789963847)
public Order(long id, long customerId) {
    this.id = id;
    this.customerId = customerId;
}

@Generated(hash = 1105174599)
public Order() {

}

...
...

}

@entity
public class Customer {

@Id long id;
...

}

When I call in the activity and setCustom () will throw an exception

    Customer customer=new Customer(0,"test");
    Order order=new Order(0,0);
    order.setCustomerId(0);
    order.setCustomer(customer);   // This code

    orderBox.put(order);

java.lang.IllegalStateException: java.lang.NoSuchFieldException: __boxStore

at io.objectbox.internal.ReflectionCache.getField(ReflectionCache.java:31)

at io.objectbox.relation.ToOne.ensureBoxes(ToOne.java:73)

at io.objectbox.relation.ToOne.setTarget(ToOne.java:126)

at com.mj.rx.practice.no_sql.Order.setCustomer(Order.java:80)

In-Memory Support?

A full in-memory / non-persistent implementation could be very useful for testing and for complex caches.

I don't see anything in the documentation indicating this is currently a feature.

Difference with other orms?

What is the most biggest difference between ObjectBox and (GreenDao3.2, Realm)?

I have read the feature in the document, but i still can't understand its advantage. GreenDao3.2 will be replaced by ObjectBox?

Thank you very much!

To One Relation improvements

Seeing the code generated for @Relation annotation, I think its not the right way to do it, the getter for lets say ClassA should check if the value is null first, and if it is, then should lookup for the One to One relation and query upon, however currently, the library forces us to always use the relationship generated method to return the data, how about if the data is not yet being saved? and we would like to display the result from the api immediately, because currently i can't seem to display the data returned due to the relationship generated code and the enforcing of loading the data for the variable from the objectBox which causes our variable to always be null.

Random crash while database inserts

While testing i have noticed a crash

Device:
Nexus 6p
Android 7.1.2

I got this crash while inserting entities to the database in an background thread.

02-28 11:43:24.902 11071-11221/my.package.name A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x7304a4dffe in tid 11221 (AsyncTask #1)
                                                                
                                                                [ 02-28 11:43:24.913   382:  382 W/         ]
                                                                debuggerd: handling request: pid=11071 uid=10300 gid=10300 tid=11221
02-28 11:43:24.991 11246-11246/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
02-28 11:43:24.992 11246-11246/? A/DEBUG: Build fingerprint: 'google/angler/angler:7.1.2/.../...:user/release-keys'
02-28 11:43:24.992 11246-11246/? A/DEBUG: Revision: '0'
02-28 11:43:24.992 11246-11246/? A/DEBUG: ABI: 'arm64'
02-28 11:43:24.992 11246-11246/? A/DEBUG: pid: 11071, tid: 11221, name: AsyncTask #1  >>> my.package.name <<<
02-28 11:43:24.992 11246-11246/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x7304a4dffe
02-28 11:43:24.992 11246-11246/? A/DEBUG:     x0   0000000000000001  x1   0000007204a5a0e6  x2   0000000000000000  x3   0000000000000011
02-28 11:43:24.992 11246-11246/? A/DEBUG:     x4   0000000000000000  x5   000000000000011d  x6   0000007205f59994  x7   0000000000000000
02-28 11:43:24.992 11246-11246/? A/DEBUG:     x8   0000007304a4dfee  x9   0000000000000000  x10  0000000000000001  x11  000000000000000c
02-28 11:43:24.992 11246-11246/? A/DEBUG:     x12  0000007202db6e40  x13  0000000000000004  x14  000000721f6a9984  x15  0000000000000000
02-28 11:43:24.992 11246-11246/? A/DEBUG:     x16  0000007204ce5398  x17  0000007223331800  x18  000000000000003e  x19  0000007202824b38
02-28 11:43:24.992 11246-11246/? A/DEBUG:     x20  0000000000000011  x21  0000000000000000  x22  000000721808d080  x23  0000007204a5a0de
02-28 11:43:24.992 11246-11246/? A/DEBUG:     x24  0000000000000000  x25  0bc1a9fd9bd644c0  x26  0000007204a4e000  x27  000000007ffffff8
02-28 11:43:24.992 11246-11246/? A/DEBUG:     x28  0000007203f04000  x29  00000071ff328ac0  x30  0000007204c41c04
02-28 11:43:24.992 11246-11246/? A/DEBUG:     sp   00000071ff328a50  pc   0000007204c41c34  pstate 00000000a0000000
02-28 11:43:24.997 11246-11246/? A/DEBUG: backtrace:
02-28 11:43:24.997 11246-11246/? A/DEBUG:     #00 pc 000000000009ec34  /data/app/my.package.name-1/lib/arm64/libobjectbox.so
02-28 11:43:24.997 11246-11246/? A/DEBUG:     #01 pc 000000000009f37c  /data/app/my.package.name-1/lib/arm64/libobjectbox.so (mdb_cursor_get+200)
02-28 11:43:24.997 11246-11246/? A/DEBUG:     #02 pc 000000000004c6ac  /data/app/my.package.name-1/lib/arm64/libobjectbox.so (_ZN9objectbox11IndexCursor13findIdsScalarImEEmT_PNSt6__ndk16vectorImNS3_9allocatorImEEEE+120)
02-28 11:43:24.997 11246-11246/? A/DEBUG:     #03 pc 0000000000049950  /data/app/my.package.name-1/lib/arm64/libobjectbox.so (_ZN9objectbox6Cursor16findBacklinkKeysEPNS_8PropertyEmRNSt6__ndk16vectorImNS3_9allocatorImEEEE+124)
02-28 11:43:24.997 11246-11246/? A/DEBUG:     #04 pc 00000000000abb08  /data/app/my.package.name-1/lib/arm64/libobjectbox.so (Java_io_objectbox_Cursor_nativeGetBacklinkEntities+144)
02-28 11:43:24.997 11246-11246/? A/DEBUG:     #05 pc 00000000009f05dc  /data/app/my.package.name-1/oat/arm64/base.odex (offset 0x999000)
02-28 11:43:26.468 412-412/? E/lowmemorykiller: Error writing /proc/11071/oom_score_adj; errno=22
                                                
                                                [ 02-28 11:43:26.469   382:  382 W/         ]
                                                debuggerd: resuming target 11071
02-28 11:43:26.513 928-3514/? E/InputDispatcher: channel 'a5e34c1 my.package.name/my.package.name.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!

Improve Kotlin support

Right now entities must be defined in Java. This is because the ObjectBox Gradle plugin uses JDT to parse and modify Java code.

Possible options:

  • Find (wait for) a Kotlin AST library like JDT
  • (Also) support plain annotation processing with its limitations (no modifications of existing sources)
  • ?

Support for secure private data storage

Note: it is already possible to use @Convert and your encryption implementation to encrypt single properties. See an example below.


Allow configuring the proprietary serialization format to include a layer of security.

Suggestions:

  • Full document encryption
  • Obfuscate fields via @annotation

Provide consumer proguard configuration

Currently, any android build fails if minifyEnabled true is enabled. The source is, sun.misc.Unsafe, since -dontwarn sun.misc.Unsafe solves the issue.

Suggested solution is, add a consumer proguard file in the library project: consumerProguardFiles 'proguard-rules.pro' with at least -dontwarn sun.misc.Unsafe in it.

MacOS support (desktop/server)

ObjectBox runs on Android, Linux, and Windows. Add MacOS support.

Note, that you can use MacOS to create Android apps with ObjectBox, of course.

Support to many-to-many relationships

I've tried to create simple many-to-many relationship using a auxiliary object, but it didn't work.

@Entity
public class Owner {
    @Id long id;

    @Relation(idProperty = "ownerId")
    List<PetOwner> pets;
}


@Entity
public class Pet {
    @Id long id;

    @Relation(idProperty = "petId")
    List<PetOwner> owners;
}

@Entity
public class PetOwner {
    @Id long id;

    long petId;
    long ownerId;

    @Relation Owner owner;
    @Relation Pet pet;
}

When I compile my project. I get this code generated:

// THIS CODE IS GENERATED BY ObjectBox, DO NOT EDIT.

/**
 * Cursor for DB entity "Owner".
 */
public final class OwnerCursor extends Cursor<Owner> {

    private static Properties PROPERTIES = new Owner_();


    // Property IDs get verified in Cursor base class

    public OwnerCursor(Transaction tx, long cursor) {
        super(tx, cursor, PROPERTIES);
    }

    @Temporary
    public OwnerCursor() {
    }

    @Override
    public final long getId(Owner entity) {
        return entity.getId();
    }

    /**
     * Puts an object into its box.
     *
     * @return The ID of the object within its box.
     */
    @Override
    public final long put(Owner entity) {
       //**----->>>> MISSING RETURN STATEMENT**
    }

    // TODO @Override
    protected final void attachEntity(Owner entity) {
        // TODO super.attachEntity(entity);
        entity.__boxStore = boxStoreForEntities;
    }

    // TODO do we need this? @Override
    protected final boolean isEntityUpdateable() {
        return true;
    }

I've tried to do something simpler, but it's not supported yet, as said in the documentation:

Something like

@Entity
public class Pet {
   @Id long id;
   @Relation
    List<Owner> owners;
}

@Entity
public class Owner {
    @Id long id;
    @Relation
    List<Pet> pets;
}

would be much nicer, I think.

Fetching plugin takes forever

I'm setting up ObjectBox on an existing project. After adding the plugin to the build script class path, building the project takes forever:

root build.gradle:

buildscript {
    repositories {
        jcenter()
        maven { url "http://objectbox.net/beta-repo/" }
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0-rc1'
        ...
        classpath 'io.objectbox:objectbox-gradle-plugin:0.9.8'
    }

Without io.objectbox on the class path, running ./gradlew clean --profile takes about 10 seconds

When I add io.objectbox back, running the same ./gradlew clean --profile takes about 5 minutes.

IllegalArgumentException: Property is not a integer scalar type: Relation

I get this wrong, but I cannot figure out how to do it.

I have 2 simple classes

@Entity public class Author {

  @Id private long id;
  private String author_id;
  private String fullName;
....
@Entity public class Book {

  @Id private long id;
  private String book_id;
  private String title;
  @Relation Author author;
  long authorId;  // <---- this one was autogenerated after I enabled the @Relation Author author;
....

Now I want to query all book that have Author X.

The query that I tried (and combinations) is:

Author author = authorBox.query().equal(Author_.fullName, "Mark Twain").build().findFirst();
// all good here

List<Book> bookList = bookBox.query().equal(Book_.authorId, author.getId()).build().find();
!?

the last query fails with the error:

IllegalArgumentException: Property is not a integer scalar type: Relation.

Support entity with parent class

Hello Team,

I have a Entity class "Child" which extends another class "Parent".
@Entity public class Child extends Parent

public class Parent

In my parent class, I have a method getPictures().

When I compile, I have this Gradle error:
Error:Execution failed for task :app:objectbox. > Found 1 problem(s) parsing "/Users/..../Child.java". First problem: Pb(100) The method getPictures() is undefined for the type Child (67108964 at line 54). Run gradle with --info for more details.

Actually, It doesn't seem possible to have an Entity class with an extended class, isn't it ?

Thanks for your work !

Support list/array type properties

It should be easy to implement properties of type int[] or List.

Affects also queries however:

  • how is something like "greater than X" defined? All values? At least one value? Maybe we would need additional info here

Support custom serializers

Some non-native type fields may be serialized simply. It would be good to have them serialized automagically (or with some adaptation code of some sort) so that they can be easily accessed/changed without having to care about how they're actually stored.

The simplest example I have is a Calendar object, which would be serialized to a long.

Duplicate getter and setter

@entity
public class TabloAB {
@SerializedName("id")
@expose
@id(assignable = true)
private Long id;
@SerializedName("alan1")
@expose
private String alan1;
@SerializedName("alan2")
@expose
private String alan2;
}

This is my class decleration. When I click Make Project it generates automatically getters and setters for all properties. But when I clicked the play button or make project button again it regenerates the id getter and setter. So, can not compile project. I have 6 class uses @entity annotation but I have this problem with 4 classes. @SerializedName and @expose annotations not effect this. Because other 2 classes don't have this problem.

Support custom object persisters

Sometimes we want to persist objects of custom types. It's quite easy to convert such object (Date to long, Enum to String, any object to byte array) but it's not great to hold such logic in model class.
Examples:
@Property(persister = EnumPersister.class) RecordType type;
@Property(persister = UuidPersister.class) UUID idFromServer;

Also Persister can be forced (by base interface) to implement comparison operations or leave them unimplemented and not allow such comparison in queries.

adding new fields to an entity doesn't work as I think it should

maybe I do something wrong. but here's what I do

  1. I have the Note.class
@Entity
public class Note {

  @Id
  private long id;

  private String text;
  private String comment;
  private Date date;
 ...

I insert some records into it

Note note = new Note(0, noteText, comment,  new Date());
notesBox.put(note);

I want to add a new field to it called author. so I do

@Entity
public class Note {

  @Id
  private long id;

  private String text;
  private String comment;
  private Date date;
  private String author;
 ...

I remove the generated methods (or just remove the hash) and rebuild it.
It regenerates the constructor and makes the getters and setters for the new field.

I put some records with an author.

Note note = new Note(0, noteText, comment,  new Date(), "Jim Bean");
notesBox.put(note);

but when I try to read it

[ (MainActivity.java:66)#listNotes ] Note: Note{id=11, text='d7ea381d-36e2-4166-85f1-47cf27f8d5f8', comment='Added on Feb 18, 2017 8:20:18 AM', date=Sat Feb 18 08:20:18 PST 2017, author=null}

so the new field is with "null"

am I doing something wrong ?

Booleans / Complex types in queries

It would be great if one could use actual boolean values in queries using equal.

Also: using a Date or other complex types (that utilizes compareTo/equals) in queries using greater/less.

One of the fields can not be saved until extra field is added

I have a POJO class that looks like this:

        private String name;
	private String packageName;
	private String category;
	@Transient
	private Drawable icon;
	private boolean permission;
	@Id
	private long id;

	private AppInfo(String packageName) {
		this.packageName = packageName;
		setPermission(true);
	}

Whenever i put the object of this class to objectbox, category field is not being saved and is always null if I query objectbox after saving. But if I add any extra field to the class and try to save it, this field can not be saved and category can. So is it bug or I am doing smth wrong?

Support array types with Converter

Im getting the following error when im query the entity that is using an converter:

 io.objectbox.exception.DbException: Entity is expected to have this constructor: Group(JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;ZLjava/lang/String;ZZZZL[J;)V

The constructor:

public Group(long id, String ..., String ..., String ..., boolean ..., String ...,
            boolean ..., boolean ..., boolean ..., boolean ..., long[] deviceIds)

The Entity converter usage:

@Convert(converter = DeviceIdConverter.class, dbType = String.class)
private long[] deviceIds;

The Converter Class:

public class DeviceIdConverter implements PropertyConverter<long[], String> {

    private static final ByteString SEMICOLON = ByteString.decodeBase64(";");

    @Override
    public long[] convertToEntityProperty(String s) {
        if (s == null) {
            return new long[0];
        }
        try {
            long[] ids = new long[0];
            Buffer buffer = new Buffer();
            buffer.writeUtf8(s);
            long index;
            while ((index = buffer.indexOf(SEMICOLON)) != -1) {
                ids = add(Long.parseLong(buffer.readUtf8(index - 1)), ids);
            }
            return ids;
        } catch (IOException io) {
            io.printStackTrace();
            return new long[0];
        }
    }

    public long[] add(long id, long[] values) {
        long[] anotherArray = new long[values.length + 1];
        System.arraycopy(values, 0, anotherArray, 0, values.length);
        anotherArray[values.length] = id;
        return anotherArray;
    }

    @Override
    public String convertToDatabaseValue(long[] integers) {
        Buffer buffer = new Buffer();
        for (long value : integers) {
            buffer.write(SEMICOLON);
            buffer.writeUtf8(String.valueOf(value));
        }
        return buffer.toString();
    }
}

Unique properties

It would be great to have unique annotation so that a put operation can detect, that this row is already existing and needs to be updated instead of creating a new one.

I know this is possible already by making it the @id column and assignable, but sometimes one needs multiple unique columns.

Also this would allow to have different types of keys as one could possibly also use a string.

FAQ: Library overhead

It'd be useful to have some data in the FAQ about the databases overhead

  • size
  • method count
  • how much can pro-guard reduce

Improve support for other languages (UTF-8 characters) in queries

Let's get a simple object with Id and Indexed field called name. Then fill it with two lagnguage values (russian and english in my case). Now make a query like

query().order(CallTheme_.name).build().subscribe().observer ...

The result is shown in application screenshot and you can see that case insensitive collation order for english language is different that a collation order for russian, i.e. did't work for russian either.

image

Clarify License

So over the weekend I've invested some time in one of my projects to rewrite all SQLite code to Objectbox. The current Beta License (http://greenrobot.org/objectbox/license/) and the absence of the open source code is problematic though. Our project is open source under MIT / GNU and currently we cannot merge the changes and deploy the code till we find a resolution.

Once a an updated License OR a final release is available, you need to stop using any of the material made available to you with this beta license and switch to the then current release version with its terms and conditions

This is simply not reasonable. If there are plans to sell the code or a per use license, then this eliminates OB as a solution for our app. It would be great to know in advance, before I invest too much more of my time.

Is there a timeline for the beta? What will be the license for objectbox? greenDAO does not seem to have a license? When will the code be published?

Object Browser App

Allow to open ObjectBox databases with a generic browser.

Main question: should this be something you can integrate into an app? Or do you prefer an desktop app? Or a web app?

Pro app:

  • no need to pull database files to the desktop

Pro desktop:

  • More screen estate
  • Also works for non-Android databases, e.g. desktop apps and unit tests

Pro web app (e.g. write server in Kotlin with embedded netty):

  • More screen estate
  • Can be accessed locally on the device or on the desktop
  • Also works for non-Android databases, e.g. desktop apps and unit tests
  • Remotely accessible, e.g. you could use ObjectBox on a server and connect to it

Pro Stetho

  • Existing infrastructure

What would you prefer and why?

ID is higher or equal to internal ID sequence

Hi,
First thanks for the great library even though its still missing some major(at least for me) features like auto generetad id, string id, auto relation etc.

I tried to manually set id for each of my entities since there's no id coming from source. Then i get this exception java.lang.IllegalArgumentException: ID is higher or equal to internal ID sequence: 2 (vs. 2). Use ID 0 (zero) to insert new entities.

        int id = 0;
        for (VehicleType vehicleType : vehicleTypes) {
            vehicleType.setId(id++);
        }

I tried to use random but it didn't work either

       Random random = new Random();
        for (VehicleType vehicleType : vehicleTypes) {
            vehicleType.setId(random.nextInt());
        }

Can you tell me how can i achieve this?

Kotlin entity support

I saw in the reddit thread that this was not available, but desired - it'd be great if we could use Kotlin as a first-class citizen in regards to creating Entities in ObjectBox.

Support "NotIn" in QueryBuilder

Hello Team,

I want to use the QueryBuilder to do a "notIn" but it doesn't exist.
What do you think to add this feature ?

Thanks a lot !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.