mapstruct

MapStruct implementation is not working in Spring Boot Web Application

点点圈 提交于 2019-12-21 20:33:06
问题 I am a newbie to Spring Boot and MapStruct Tool. Earlier, A Project(written by other team using these technologies) is not starting up. Then, I had made some changes in Mapper Abstract Class but now mapper object is coming as null on application startup. Mapper Abstract Class: @Mapper(componentModel = "spring") public abstract class UserAndEmployeeMapper { public UserAndEmployeeMapper INSTANCE = Mappers.getMapper( UserAndEmployeeMapper.class ); @Mapping(source = "username", target = "name")

Mapstruct: Clear Collection on update when using Adders

£可爱£侵袭症+ 提交于 2019-12-20 04:32:03
问题 I try to map my DTO objects to my JPA entities. I have a Collection of children in my ParentEntity . They can be added addChild() . Using the Adder is supported by Mapstruct via the CollectionMappingStrategy (http://mapstruct.org/documentation/dev/reference/html/#collection-mapping-strategies). This works fine if I create new entities, but fails to clear the children on updating before adding the new children. The Mapstruct manual says (http://mapstruct.org/documentation/dev/reference/html/

Mapstruct: Clear Collection on update when using Adders

痴心易碎 提交于 2019-12-20 04:31:09
问题 I try to map my DTO objects to my JPA entities. I have a Collection of children in my ParentEntity . They can be added addChild() . Using the Adder is supported by Mapstruct via the CollectionMappingStrategy (http://mapstruct.org/documentation/dev/reference/html/#collection-mapping-strategies). This works fine if I create new entities, but fails to clear the children on updating before adding the new children. The Mapstruct manual says (http://mapstruct.org/documentation/dev/reference/html/

Lazy loading not working in JPA with hibernate

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-20 03:05:09
问题 I am using JPA with hibernate in my spring boot application. Whenever I try to fetch the enities using jpa methods, its returning the entity plus all the association present inside it. I wanted to fetch the associated entities on demand(lazy loading), so I have provided fetch=FetchType.LAZY in my domain class. But still its returning all the entries. Below is the code: Case.java @Entity @Table(name="smss_case") public class Case implements Serializable { /** * */ private static final long

Spring boot Mapstruct StackOverFlow Error

北慕城南 提交于 2019-12-19 08:26:11
问题 I'm using mapstruct to map my entity and dto classes... I'm having problem with a loop on my mapper class... I have no ideia what to do... This is my mapper classes @Mapper(componentModel = "spring", uses = {BrandMapper.class}) public interface VehicleTypeMapper { VehicleTypeDTO vehicleTypetoVehicleTypeDTO(VehicleType vehicleType); Iterable<VehicleTypeDTO> vehicleTypetoVehicleTypeDTO(Iterable<VehicleType> vehicleTypes); VehicleType vehicleTypeDTOtoVehicleType(VehicleTypeDTO vehicleTypeDTO); }

Java mapping: Selma vs MapStruct

我的未来我决定 提交于 2019-12-18 10:04:14
问题 Currently there are two main popular Java Object to Object mapping frameworks that supersede Dozer (http://dozer.sourceforge.net/documentation/mappings.html), they are: Selma - http://www.selma-java.org/ MapStruct - http://mapstruct.org/ With the exception of this page (http://vytas.io/blog/java/java-object-to-object-mapping-which-framework-to-choose-part-2/) I haven't been able to find much online regarding which framework is better than the other, or under what circumstances they are better

MapStruct does not generate code for Named Qualifiers without any source

ぐ巨炮叔叔 提交于 2019-12-13 03:04:57
问题 In continuation with the topic of discussion .. Mapstruct auto generated impl - maps to the wrong method I seem to be having more problems with Mapstruct , Here is the full code , could you check and let me know what is missing .. why doesnt the auto generated Impl have code for target attributes without a source ? import org.mapstruct.*; import java.util.List; @Mapper(uses = EditedPieceMapFilter.class) public interface EditedPieceMapMapper { @Mapping(target = "startAge", source = "startAge")

Use Java 8 optional with Mapstruct

旧巷老猫 提交于 2019-12-13 01:28:37
问题 I have these two classes: public class CustomerEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; private String firstName; private String lastName; private String address; private int age; private LocalDateTime createdAt; private LocalDateTime updatedAt; } and public class CustomerDto { private Long customerId; private String firstName; private String lastName; private Optional<String> address; private int age; } The problem is that Mapstruct doesn't recognize

How can I map an enum to a boolean with mapstruct?

霸气de小男生 提交于 2019-12-12 17:03:43
问题 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 @ValueMappings(), but it didn't work: @ValueMappings({ @ValueMapping(source="Y", target=true), @ValueMapping(source="N", target=false) ) Boolean map(YN value); How can I implemente this mapping? 回答1: ValueMappings are used for mapping between two Enum s. You can't use them to map an Enum to something else. For

MapStruct - mapping RealmList relationship

帅比萌擦擦* 提交于 2019-12-12 05:28:43
问题 Okay, I'm not very sure how to ask this but I'm going to try. I am using MapStruct to map my incoming network objects to database objects. I use Realm.io as my local datastore. Some of my objects have RealmList<Obj> which store their relationships, for example: public class Client extends RealmObject { @PrimaryKey private String id = UUID.randomUUID().toString(); private Date createdAt = new Date(); private Date updatedAt = new Date(); private RealmList<Contact> contacts; // <-- this guy //