I want to create an object that has a many-to-one relationship with a JHipster user entity.
I used JDL-Studio to create the following entity and relationship to User, which is imported into my Microservice as a .jh file using jhipster import-jdl:
entity Profile {
name String required
bio String
location String
photo ImageBlob
}
relationship ManyToOne {
Profile{user} to User
}
angularSuffix * with mySuffix
dto * with mapstruct
When compiling my Micro service, I get the following errors:
Profile.java:44: error: cannot find private user user character; symbol: class User location: class Profile
ProfileMapper.java:12: error: cannot find @Mapper character (componentModel = "spring", uses = {UserMapper.class,}) character: class UserMapper
ProfileMapper.java:12: : @Mapper @Mapper (componentModel = "spring", = {UserMapper.class,})
43-44 .java:
@ManyToOne
private User user;
ProfileMapper.java :
package com.moogrisoft.openseas.service.mapper;
import com.moogrisoft.openseas.domain.*;
import com.moogrisoft.openseas.service.dto.ProfileDTO;
import org.mapstruct.*;
import java.util.List;
@Mapper(componentModel = "spring", uses = {UserMapper.class, })
public interface ProfileMapper {
@Mapping(source = "user.id", target = "userId")
ProfileDTO profileToProfileDTO(Profile profile);
List<ProfileDTO> profilesToProfileDTOs(List<Profile> profiles);
@Mapping(source = "userId", target = "user")
Profile profileDTOToProfile(ProfileDTO profileDTO);
List<Profile> profileDTOsToProfiles(List<ProfileDTO> profileDTOs);
default Profile profileFromId(Long id) {
if (id == null) {
return null;
}
Profile profile = new Profile();
profile.setId(id);
return profile;
}
}
UserMapper, .
, , Microservice - .