-
Notifications
You must be signed in to change notification settings - Fork 308
Closed
Labels
bugSomething isn't workingSomething isn't working
Milestone
Description
Issue Basics
- ObjectBox version: 2.1.0
- Reproducibility: always
Reproducing the bug
Description
Querying with related ToOne entity and ToMany entities returns no results:
Persons who work at Company "1" and have an address on "Sesame Street"
Code
// get all persons who work at Company 1
val builder = personBox.query()
.equal(Person_.companyId, 1)
// ...which have an address on "Sesame Street"
builder.link(Person_.addresses).equal(Address_.street, "Sesame Street")
val result = builder.build().find()
Result is empty
// get all Person objects
val builder = personBox.query()
// .equal(Person_.companyId, 1) <- without this condition, there are results
// ...which have an address on "Sesame Street"
builder.link(Person_.addresses).equal(Address_.street, "Sesame Street")
val result = builder.build().find()
Result with Elmo Person
Initialization
...
companyBox.put(Company().apply {
id = 1
name = "Google"
})
personBox.put(Person().apply {
id = 1
name = "Elmo"
company.targetId = 1
})
addressBox.put(Address().apply {
id = 1
street = "Sesame Street"
})
personBox.get(1).addresses.applyChangesToDb {
addAll(addressBox.all)
}
Entities
@Entity
class Person {
@Id(assignable = true)
var id: Long = 0
var name: String? = null
lateinit var addresses: ToMany<Address>
lateinit var company: ToOne<Company>
}
@Entity
class Address {
@Id(assignable = true)
var id: Long = 0
var street: String? = null
var zip: String? = null
@Backlink(to = "addresses")
lateinit var persons: ToMany<Person>
}
@Entity
class Company {
@Id(assignable = true)
var id: Long = 0
var name: String? = null
@Backlink(to = "company")
lateinit var persons: ToMany<Person>
}
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working