objectbox-java: ToOne object is null inside com.jega.entity.UserEntity

I’ve entity class with ToOne relation. when we query the parent class we are seeing the exception java.lang.IllegalStateException: ToOne object is null inside com.jega.entity.UserEntity

Entity class

@Entity
data class UserEntity(
    @Id
    var id: Long = 0,
    var name: String
) {
    var address: ToOne<AddressEntity>? = null
}


@Entity
data class AddressEntity(
    @Id
    var id: Long=0,
    var streetLine: String,
    var streetLine2: String,
    var locality: String,
    var city: String,
    var state: String,
    var zipcode: String,
    var landmark: String? = null
)

Exception


java.lang.IllegalStateException: ToOne object is null inside com.jega.entity.UserEntity
at io.objectbox.Cursor.nativeFirstEntity(Native Method)
at io.objectbox.Cursor.first(Cursor.java:197)
at io.objectbox.Box.getAll(Box.java:310)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 15 (7 by maintainers)

Most upvoted comments

Closing this then as the original poster has also not replied.