Spring Boot @Mapping gives no read accessor error

Hello! I'm trying to use @mapping to map a DTo from entities My Main DTO is
public class MainDto {
private ProjectDTO project;
private TaskDTO task;
}
public class MainDto {
private ProjectDTO project;
private TaskDTO task;
}
DTOs:
public class ProjectDTO {
private UUID projectId;
private Second second;
private String name;
private String desc;
}
public class ProjectDTO {
private UUID projectId;
private Second second;
private String name;
private String desc;
}
public class SecondDTO {
private UUID secondId;
private String name;
private String desc;
}
public class SecondDTO {
private UUID secondId;
private String name;
private String desc;
}
public class TaskDTO {
private UUID taskId;
private String taskName;
}
public class TaskDTO {
private UUID taskId;
private String taskName;
}
Entities:
@Entity
public class ProjectEntity {
@Id
@Column(name = "project_id")
private UUID projectId;

@Column(name = "second_id")
private UUID secondId;

.... etc
}
@Entity
public class ProjectEntity {
@Id
@Column(name = "project_id")
private UUID projectId;

@Column(name = "second_id")
private UUID secondId;

.... etc
}
@Entity
public class SecondEntity {
@Id
@Column(name = "second_id")
private UUID secondId;

.... etc
}
@Entity
public class SecondEntity {
@Id
@Column(name = "second_id")
private UUID secondId;

.... etc
}
@Entity
public class TaskEntity {
...
}
@Entity
public class TaskEntity {
...
}
On an other file i set ans use the entities on repos, then i want to return the MainDTO:
public class main {
ProjectEntity projEntity = ...
SecondEntity sENtity = ...
TaskEntity tEntity = ...
....
}
public class main {
ProjectEntity projEntity = ...
SecondEntity sENtity = ...
TaskEntity tEntity = ...
....
}
then i got problems on mapping them: - If in main i've: MainDTO mDTO(ProjectEntity projEntity, SecondEntity sEntity, TaskEntity tEntity); it returns correctly filled the ProjectDTO and TaskDTO, except for the ProjectDTO Second, that is null. - If i try
@Mapping(target = "project.second", source = "sEntity")
MainDTO mDTO(ProjectEntity projEntity, SecondEntity sEntity, TaskEntity tEntity);
@Mapping(target = "project.second", source = "sEntity")
MainDTO mDTO(ProjectEntity projEntity, SecondEntity sEntity, TaskEntity tEntity);
works, it fill the Second, but the rest of projectDTO is empty (TaskDTO is filled). - If i try something like
@Mapping(target = "project", source = "projEntity")
@Mapping(target = "project.second", source = "sEntity")
MainDTO mDTO(ProjectEntity projEntity, SecondEntity sEntity, TaskEntity tEntity);
@Mapping(target = "project", source = "projEntity")
@Mapping(target = "project.second", source = "sEntity")
MainDTO mDTO(ProjectEntity projEntity, SecondEntity sEntity, TaskEntity tEntity);
or
@Mapping(target = "project.description", source = "projEntity")
@Mapping(target = "project.second", source = "sEntity")
MainDTO mDTO(ProjectEntity projEntity, SecondEntity sEntity, TaskEntity tEntity);
@Mapping(target = "project.description", source = "projEntity")
@Mapping(target = "project.second", source = "sEntity")
MainDTO mDTO(ProjectEntity projEntity, SecondEntity sEntity, TaskEntity tEntity);
it gives the error: java: no read accessor for property "project" in tagret type Someone has tips for this? THank you so much
3 Replies
JavaBot
JavaBot5mo ago
This post has been reserved for your question.
Hey @Romans! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here. 💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
JavaBot
JavaBot5mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Want results from more Discord servers?
Add your server