mapstruct Questions
2
How can you specify a defaultValue when mapping a DTO using MapStruct? The following constructs did not work
@Mapping(target = "used", defaultValue = "0")
MyDTO toDto(MyEntity entity);
@Mapping(t...
17
Using latest Springboot and MapStruct versions and building with Maven, I am trying to implement the "Start Here" example given in the official MapStruct site
My code is even simpler:
pom.xml
&l...
Muzzle asked 10/5, 2020 at 10:31
1
I have a FlatDTO that needs to be mapped to a nested Response containing InfoData and MetaData
The code for the response is generated by OpenAPI. So the below definitions can't be changed.
package ...
Bloxberg asked 21/11, 2022 at 5:36
4
Solved
I'm having trouble using MapStruct version 1.4.1 when I'm trying to implement my own mapping. This is code that I wrote:
package com.kucazdravlja.user.mappers;
import com.kucazdravlja.user.dto.Not...
Thresathresh asked 31/12, 2020 at 6:46
5
Solved
I'm new to mapstruct. I'm trying to map ItemInfo to Item object and the following are my classes.
public class ItemInfo {
private String itemOwner;
private String itemOwnerArea;
//getters and ...
5
Solved
I want to check null in method
@Override
public void updateFooFromNonNullAttributesOfDto(FooDto fooDto, Foo foo) {
if ( fooDto== null ) {
return;
}
if ( fooDto.getBar() != null ) {
site.setBar...
6
I am trying to map nested properties using mapstruct 1.2.0.CR2.
(Example map customer.address.houseNumber to userDTO.homeDTO.addressDTO.houseNo ).
Expectation : I do not want to set the addressDT...
2
Solved
I have some auto-generated enums that I need to map to boolean values in a MapStruct mapper. They go like this:
enum YN {
Y("Y"), N("N")
}
enum ZO {
_0("0"), _1("1")
}
I've tried to use @Valu...
2
PageInfoDto<T>:
public class PageInfoDto<T> {
private int currentPageNum;
private int totalPageNum;
private int perPageNum;
private int totalItemNum;
private List<T> list;
}
...
3
// Driver model
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Driver {
private String driverName;
private String licenseNumber;
}
// Car model
@Data
@AllArgsConstructor
@NoArgsConstr...
Resignation asked 4/8, 2022 at 17:26
3
I'm trying to configure SpringBoot (v2.6.2) with Lombok and MapStruct, already configured the maven compiler plugin and the lombok-mapstruct-binding (annotationProcessorPaths) but the lombok classe...
Hesson asked 12/1, 2022 at 17:8
7
Solved
I'm trying to use MapStruct to map convert between dto and entity objects, however the generated mapper implementation only returns empty mapped object.
BeerMapperImpl
@Generated(
value = "or...
Projectionist asked 5/11, 2020 at 0:11
10
Solved
I'm using MapStruct, mapstruct-jdk8 version 1.1.0.Final and defining abstract class that I inject via Spring.
I'm looking at how to be able to test them via Junit Test ?
I've basicaly a main mappe...
Oralee asked 24/7, 2017 at 8:13
10
Solved
I need to inject a spring service class in the generated mapper implementation, so that I can use it via
@Mapping(target="x", expression="java(myservice.findById(id))")"
Is this applicable in ...
4
Solved
I am using MapStruct for mapping a DTO to an entity and vice versa in my Spring Boot application.
Is there a way to map empty strings to null using @Mapping?
3
When trying to map nested Object using @Data and @Builder, mapStruct throw the following errors: "No read accessor found for property "profile" in target type."
@Mapper(componen...
Lanai asked 9/10, 2020 at 21:37
3
Solved
Have a target type, formed by Lombok:
@Data
@Builder
class Target {
private final String a;
}
and have a DTO:
@Value
@Builder
class DTO {
private final String a;
}
Mapper:
@Mapper(componen...
8
I'm having trouble using Mapstruct.
I am using a @Mapper annotated interface with @AfterMapping inside like follow:
@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface Config...
2
Solved
Haven't figured out how to pass in additional arguments or an alternative.
Currently I'm mapping an Order and OrderLines. Both objects are different and need @mappings. Example I have an Order and...
3
Solved
I have Car:
id
brand
model
owner
And CarDTO:
id
brand
model
In my service class I'm passing additional parameter "owner" and I need to convert the list.
Is it possible to add "ow...
23
Solved
Tech Stack being used :
Java 8
MapStruct : 1.2.0.Final
Lombok: 1.16.18
IDE: IntelliJ - Lombok Plugin already installed
Initially, I faced issues when I removed getters and setters and added @G...
Nerta asked 6/12, 2017 at 14:14
12
Solved
I am writing an MVC REST application with Spring Boot and Hibernate. I decided to do DTO mapping using MAPSTRUCT. It seems that I did everything according to the guide, but an error is issued. What...
Siouan asked 22/7, 2020 at 13:7
5
mvn compilation using Idea works fine.
Fails during App.main start.
Works well on older Idea on other PC on Ubuntu.
ENV:
Intellij 2020.3.2 as admin;
Java 15.02;
Windows 10 x64;
latest mapstruct...
Pteranodon asked 11/3, 2021 at 22:0
5
Solved
When using multiple arguments in a @Mapper, it seems that the @Context arguments is unreachable
public interface MyMapper {
@Mapping(target="target1", source="arg1.arg") //wor...
Schiedam asked 15/5, 2019 at 12:36
3
Solved
How do I completely disable using "builders" in MapStruct? I don't want to use them at all as they are causing all kinds of issues for me.
I created the service file under META-INF (I would prefer...
Gamaliel asked 12/2, 2019 at 17:25
1 Next >
© 2022 - 2024 — McMap. All rights reserved.