Objectbox-java: List<String> error: Relation target class 'String' defined in class could not be found

Created on 29 Mar 2019  ·  6Comments  ·  Source: objectbox/objectbox-java

e: 错误: [ObjectBox] Relation target class 'String' defined in class 'ResultBean' could not be found (is it an @Entity?)
:app:kaptAliDebugKotlin FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:kaptAliDebugKotlin'.

    Compilation error. See log for more details

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 1s

Most helpful comment

ObjectBox does not support List<String>. It assumes you mean ToMany<String>.

You need to define a converter for List<String>.

@Convert(converter = StringListConverter::class.java, dbType = String::class.java)
var deadlineSelect: List<String>? = null

https://docs.objectbox.io/advanced/custom-types

-Uwe

All 6 comments

If I understand this correctly: you can only have relations to other @Entity classes.
https://docs.objectbox.io/relations

// WORKS
@Entity
public class Order {
    @Id public long id;
    public ToOne<Customer> customer;
}
@Entity
public class Customer {
    @Id public long id;
}

// DOES NOT WORK
@Entity
public class Order {
    @Id public long id;
    public ToOne<String> customer;
}

-Uwe

X}O~R5EEV)$PLWW0 G505MG
F @ <a href="Q@HKU3L@">Q@HKU3L@</a>{NQUE_ZT}2N
原有bean 是这样 如何变成object——box 所需格式 转换器 该如何写

ObjectBox does not support List<String>. It assumes you mean ToMany<String>.

You need to define a converter for List<String>.

@Convert(converter = StringListConverter::class.java, dbType = String::class.java)
var deadlineSelect: List<String>? = null

https://docs.objectbox.io/advanced/custom-types

-Uwe

谢谢了 , object-box 如何去除重复数据呢
Translation: Thank you, how does object-box remove duplicate data?

I'm not sure what you mean by that. Can you given an example?
-Uwe

Closing this issue due to inactivity. :zzz: Feel free to re-open with more details or submit a new issue.

Was this page helpful?
0 / 5 - 0 ratings