如何在Kotlin中使用注释TypeDefs?

时间:2018-04-17 09:55:59

标签: java hibernate kotlin

此Java代码段的等效Kotlin代码是什么?

@Data
@Entity
@TypeDefs({
        @TypeDef(name = "string-array", typeClass = StringArrayType.class),
        @TypeDef(name = "int-array", typeClass = IntArrayType.class),
        @TypeDef(name = "json", typeClass = JsonStringType.class),
        @TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)
})
public class Parent implements Serializable {
    //....
}

最后跟随代码工作。

@TypeDefs(
        TypeDef(name = "string-array", typeClass = StringArrayType::class),
        TypeDef(name = "int-array", typeClass = IntArrayType::class),
        TypeDef(name = "json", typeClass = JsonStringType::class),
        TypeDef(name = "jsonb", typeClass = JsonBinaryType::class)
)

1 个答案:

答案 0 :(得分:1)

试试这个。

@Data
@Entity
@TypeDefs(
  TypeDef(name = "string-array", typeClass = StringArrayType::class.java),
  TypeDef(name = "int-array", typeClass = IntArrayType::class.java),
  TypeDef(name = "json", typeClass = JsonStringType::class.java),
  TypeDef(name = "jsonb", typeClass = JsonBinaryType::class.java))
class Parent : Serializable