Objectbox-java: fields has private access in .kt class

Created on 9 Sep 2017  路  10Comments  路  Source: objectbox/objectbox-java

Please help us to fix issues asap: to reduce checking with you back and forth, use the template below. Replace italic sections with your input.
For __support questions__, please use stackoverflow with the [objectbox] tag - we get notified.

Basics

  • ObjectBox version (are using the latest version?): 1.0.0
  • Reproducibility: [always]

Reproducing the bug

Description

@greenrobot I started using this but during build entities i have got below error from generated cursor.java class

Code

var addressLocationBox: ToOne? = null

collect313311(cursor, 0, 0, 0, null, 0, null, 0, null, 0, null, __ID_addressForeignKeyId, entity.addressForeignKey.getTargetId(), _ __ID_operationInQueue, entity.getOperationInQueue(), __ID_priority, entity.getPriority(), __ID_status, entity.getStatus(), 0, 0, 0, 0);

Logs & stackstraces

Error:(90, 50) error: addressLocationBox has private access in AddressBox

Entities

AddressBox.kt

Most helpful comment

@sigfridod Thanks for reporting, will look into this very soon.

As a workaround, you should be able to make the Kotlin field visible using @JvmField:

@JvmField var addressLocationBox: ToOne? = null

Does that help for now?

All 10 comments

@sigfridod Thanks for reporting, will look into this very soon.

As a workaround, you should be able to make the Kotlin field visible using @JvmField:

@JvmField var addressLocationBox: ToOne? = null

Does that help for now?

Was about to open the very same issue ;-)
Using @JvmField seems to help.

@greenrobot thanks it helps.

One more things, is it possible to have @id filed of other types ? like string or double...

right now it supports only long

Check upcoming release 1.0.1

Just published 1.0.1 - please retest

Still having this issue on Kotlin 1.3.21

@raviaw Please submit a new issue with details, preferably something we can reproduce.
-ut

Hi,

Iam facing the same issue. The field which is in Object declared with ToOne is not accessible.

class Response  {
    @Id
    var id: Long = 0
    var policyID: String? = null
    var licenseKey: String? = null
    var requestId: String? = null
    @JvmField var info: ToOne<Info> ?= null

}

@Entity
class Info{
 @Id
    var id: Long = 0
    var actCode: String? = null
}

I am not able to access ,
response.info.actCode.

Can anyone tell me what iam missing here.

Thank you
Bhuvana

I found the solution,

We need to use target to access the inner object members.
Ex: response.info.target.actCode

@bhuvaneshwariarkala This is also explained in more detail in the docs: https://docs.objectbox.io/relations
-ut

Was this page helpful?
0 / 5 - 0 ratings