0

The ABCDto

@Getter
@RequiredArgsConstructor
@AllArgsConstructor
public class ABCDto
{
   private String identification;
   private String orderIdentification;

The ABCEntity:

@Entity(name = "")
@Table(name = "")
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class ABCEntity
{
   @Id
   private String identification;
   @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
   @JoinColumn(name = "orderIdentification", referencedColumnName = "identification")
   private OrderEntity orderIdentification;

The OrderEntity:

@Entity(name = "")
@Table(name = "")
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class OrderEntity
{
   @Id
   private String identification;
   ...

My MapperInterface:

@Mapper
public interface ABCMapper
{
   @Mapping(target = "orderIdentification", source = "orderIdentification.identification")
   ABCDto toABC(ABCEntity abcEntity);

The error:

No property named "orderIdentification.identification" exists in source parameter(s). Type "ABCEntity" has no properties.
emoleumassi
  • 4,881
  • 13
  • 67
  • 93
  • 2
    Usually it’s related to missing configuration when using mapstruct along with lombok (Maven Annotation Processing Configuration). Check this guide step by step: https://springframework.guru/using-mapstruct-with-project-lombok/ – Paul Marcelin Bejan Aug 15 '22 at 22:51
  • 1
    See mapstruct documentation regarding integration with lombok https://mapstruct.org/documentation/stable/reference/html/#lombok You need correctly configure it – Eugene Aug 15 '22 at 23:54
  • I don't mean to talk bad about MapStruct, but if you want to project data from entities, I would rather recommend that you take a look at Blaze-Persistence Entity-Views (https://github.com/Blazebit/blaze-persistence#entity-view-usage) which will also adapt the query behind the scenes to match exactly the data you need. – Christian Beikov Aug 17 '22 at 08:39
  • The problem here is the same as in https://stackoverflow.com/questions/47676369/mapstruct-and-lombok-not-working-together. You are most likely missing the lombok-mapstruct-binding dependency – Filip Aug 19 '22 at 08:15

0 Answers0