deo
deo

Reputation: 936

Vertx code generation failed - Illegal type java.lang.String[] of kind ARRAY

While compiling java code using vertx code generation, It failed throwing an error Illegal type java.lang.String[] of kind ARRAY.

Here is the entity used in service.

@DataObject
public Word{
...

  @Type( type = "string-array" )
  @Column(columnDefinition = "ARRAY")
  @Size(min=1, max=10)
  private String[] examples = null;

...
}

Here is the stack trace when I run mvn compile,

SEVERE: Could not generate element for xxx.Word: Illegal type java.lang.String[] of kind ARRAY java.lang.IllegalArgumentException: Illegal type java.lang.String[] of kind ARRAY at io.vertx.codegen.type.TypeMirrorFactory.create(TypeMirrorFactory.java:68) at io.vertx.codegen.type.TypeMirrorFactory.create(TypeMirrorFactory.java:43) at io.vertx.codegen.DataObjectModel.processMethod(DataObjectModel.java:366) at io.vertx.codegen.DataObjectModel.processMethods(DataObjectModel.java:352) at io.vertx.codegen.DataObjectModel.traverse(DataObjectModel.java:227) at io.vertx.codegen.DataObjectModel.process(DataObjectModel.java:163) at io.vertx.codegen.CodeGen.getDataObjectModel(CodeGen.java:189) at io.vertx.codegen.CodeGen.lambda$null$16(CodeGen.java:117) at io.vertx.codegen.CodeGen$ModelEntry.getValue(CodeGen.java:223)

Please help!

Upvotes: 1

Views: 693

Answers (1)

Julien Viet
Julien Viet

Reputation: 335

Data objects don't support arrays, so you need to use a List<String> as the types of the corresponding the getter/setter, the internal value can remain an array.

Upvotes: 1

Related Questions