Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use annotation TypeDefs in Kotlin?

What is the equivalent Kotlin code of this Java snippet?

@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 {
    //....
}

finally following code works.

@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)
)
like image 206
BigFatSea Avatar asked Apr 17 '18 09:04

BigFatSea


1 Answers

Try this.

@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
like image 167
ice1000 Avatar answered Nov 17 '22 08:11

ice1000