i am developing project using kotlin and have the following classes
DTO class
data class TestDTO (
val name: String,
val type: String
)
Model class
@Entity
data class Test (
@Column(name = "name")
val name: String? = null,
@Column(name = "type")
val type: String? = null,
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(columnDefinition = "BIGINT")
val id: BigInteger? = null
)
Mapper Class
@Mapper(componentModel = "spring", injectionStrategy = InjectionStrategy.CONSTRUCTOR)
interface TestMapper {
fun convertToTest(testDTO: TestDTO): Test
}
I expected the generated mapper will use constructor to create the Test class (the model), but the result is like below
@Component
public class TestMapperImpl implements TestMapper {
@Override
public Test convertToTest(TestDTO testDTO) {
if ( testDTO == null ) {
return null;
}
Test test = new Test();
return test;
}
}
why is it using the empty constructor of Test, can we use the Test(name, type) constructor?
i am developing project using kotlin and have the following classes
DTO class
Model class
Mapper Class
I expected the generated mapper will use constructor to create the Test class (the model), but the result is like below
why is it using the empty constructor of Test, can we use the Test(name, type) constructor?