Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ToOne need to use converter? #1108

Closed
soroksorok opened this issue Dec 6, 2022 · 2 comments
Closed

ToOne need to use converter? #1108

soroksorok opened this issue Dec 6, 2022 · 2 comments
Labels
bug Something isn't working more info required Further information is requested

Comments

@soroksorok
Copy link

Hi all,

Disclaimer, this is my first time using ObjectBox

Im trying to use relation

@Entity
data class Customer(
        @Id var id: Long = 0
) {    
    @Backlink(to = "customer")
    lateinit var orders: ToMany<Order>
}

@Entity
data class Order(
        @Id var id: Long = 0,
        var name: String? = ""
) {
    lateinit var customer: ToOne<Customer>
}

From the above classes, Im getting error as below
Cannot figure out how to save this field into database. You can consider adding a type converter for it.

Not sure if I did this correctly or not, need help figuring out why its saying this.
Do I actually need converter for using ToOne?

Thanks in advance. Btw great project

@soroksorok soroksorok added the bug Something isn't working label Dec 6, 2022
@greenrobot-team
Copy link
Member

Thanks for reporting. However, this error message is not familiar. This should work without issue, assuming your code imports the ToOne class from the io.objectbox package.

Can you share the exact error message? Also, are you using the latest version of ObjectBox? If not, which one?

If possible supply the following info:

**Basic info (please complete the following information):**
 - ObjectBox version (are you using the latest version?): [e.g. 2.7.0]
 - Reproducibility: [e.g. occurred once only | occasionally without visible pattern | always]
 - Device: [e.g. Galaxy S20]
 - OS: [e.g. Android 10]

@greenrobot-team greenrobot-team added the more info required Further information is requested label Dec 12, 2022
@github-actions
Copy link

github-actions bot commented Jan 3, 2023

Without additional information, we are unfortunately not sure how to resolve this issue. Therefore this issue has been automatically closed. Feel free to comment with additional details and we can re-open this issue.

@github-actions github-actions bot closed this as completed Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working more info required Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants