question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[1.1.0] ToOne<Some> is null

See original GitHub issue
@Entity
public class Product {
    @Id
    private long id;
    private String title= "Product №";
    private String desc;
    public ToOne<Category> category;

    public ToOne<Category> getCategory() {
        return category;
    }

    public void setCategory(ToOne<Category> category) {
        this.category = category;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title= title;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }
}
@Entity
public class Category {
    @Id
    private long id;
    private String title;

    public Category(String title) {
      this.title = title;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }
}
boxStore.runInTx(new Runnable() {() ->
                    Category category = new Category("Stuff");
                    categoryBox.put(category);
                    Product product = new Product();
                    product.category.setTarget(category);  // product.category  NPE
                    productBox.put(product);
            });

product.category is null

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
greenrobot-teamcommented, Oct 10, 2017

ObjectBox modifies the constructor by doing byte code modification to add initialization code for ToOne and ToMany fields. If you mark the constructor private, ObjectBox can not call it when creating an object, hence the ToOne and ToMany are never initialized (null). -ut

0reactions
greenrobot-teamcommented, Apr 17, 2018

Closing. Note that there were improvements to the transformer in the latest releases, including the new preview release 1.5.0-RC. Please open a new issue with details if you encounter new issues. -ut

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to setup your own MQTT Broker - O'Brien Labs
First install Mosquitto, which is the name of the MQTT software. ... If you stopped here and did sudo service mosquitto start you'll...
Read more >
NetGuardian 420 - DPS Telecom
With the NetGuardian, you can: • Monitor 20 discrete alarms, 32 ping alarms, and up to 6 analog alarms. • Control remote site...
Read more >
AP-51xx Access Point - Barcode Datalink
NOTE If using an AP-5131 model access point, a null modem cable is required. If ... After a downgrade from 1.1/1.1.0 to 1.0....
Read more >
AP-51xx Access Point Product Reference Guide (Part - Yumpu
NOTEIf using an AP-5131 model access point, a null modem cable is required. ... After a downgrade from 1.1/1.1.0 to 1.0.
Read more >
The Practical Guide to Public Key Infrastructures (version 1.5.0)
following parameters on both ends: -cipher NULL-SHA. ... integrity to one, some or all endpoints depending on who offered a certificate. When.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found