Skip to content

DbException: Order: Unsupported type for property price_amount (Float) #224

@ajans

Description

@ajans

Issue Basics

  • ObjectBox version (are using the latest version?): 1.1.0
  • Reproducibility: always

Reproducing the bug

Description

I try to sort a list of entities of type SoluteNOffer by a Float-property with the name price_amount, which fails with a DbException: Order: Unsupported type for property price_amount.

I did not find any information anywhere about which field-types are supported for ordering result-collections or that there are any restrictions in place.

The stacktrace points to QueryBuilder.nativeBuild(Native Method), which doesn't help either.

Why isn't ordering of Float-properties supported and is there a list of supported property-types?

Thank you for looking into this!

Arne Jans

Code

The generated property of the Property-class SoluteNOffer_ looks like this:
public final static Property price_amount = new Property(9, 10, Float.class, "price_amount");
The query-code with the order-statement looks like this:

    public List<SoluteNOffer> getSoluteNOffersById(long[] offerIds) {
        Box<SoluteNOffer> offerBox = getBoxStore().boxFor(SoluteNOffer.class);
        return offerBox.query()
                .in(SoluteNOffer_.id, offerIds)
                .order(SoluteNOffer_.price_amount)
                .build().find();
    }

Logs & stackstraces

java.lang.RuntimeException: Unable to start activity ComponentInfo{de.pricepretzel.android/de.billiger.android.sparberater.activities.OfferListActivity}: io.objectbox.exception.DbException: Order: Unsupported type for property price_amount
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
    at android.app.ActivityThread.-wrap11(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
    at android.os.Handler.dispatchMessage(Handler.java:105)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6541)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
 Caused by: io.objectbox.exception.DbException: Order: Unsupported type for property price_amount
    at io.objectbox.query.QueryBuilder.nativeBuild(Native Method)
    at io.objectbox.query.QueryBuilder.build(QueryBuilder.java:164)
    at de.billiger.android.sparberater.service.api.soluten.persistence.SoluteNBoxStore.getSoluteNOffersById(SoluteNBoxStore.java:67)

Entities

@Entity
public class SoluteNOffer {
    public Float price_amount;
}

Misc

Would introducing an int-property and using it for ordering work around this issue, or is there a better approach?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions