jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.54k stars 4.02k forks source link

Generated Mappers causing cyclic method call when upgrading from v7.7.0 to v7.8.1 #18685

Closed tejaswibm-roposo closed 9 months ago

tejaswibm-roposo commented 2 years ago
Overview of the issue

I had generated JHipster - React app with v7.7.0. Now, I have upgraded it to v7.8.1 based on the documentation here by running npx jhipster upgrade command.

This re-generated the mapper classes from JPA to DTO.

The generated mapper classes in v7.8.1 are different from those generated with version v7.7.0 and there is a cyclic method calls getting generated which were not present in v7.7.0.

Motivation for or Use Case

Due to cyclic method calls, SO error is getting thrown from the server.

Reproduce the error

Generate entities as given in the jdl below.

Related issues
Suggest a Fix

Not Sure. Maybe revert mapper generator to the same as provided in v7.7.0

JHipster Version(s)

7.8.1

JHipster configuration
##### **JHipster Version(s)**

app └── generator-jhipster@7.8.1


##### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**

<details>
<summary>.yo-rc.json file</summary>
<pre>
{
  "generator-jhipster": {
    "applicationType": "monolith",
    "appsFolders": ["jhipster_app"],
    "authenticationType": "jwt",
    "baseName": "",
    "blueprints": [],
    "buildTool": "maven",
    "cacheProvider": "ehcache",
    "clientFramework": "react",
    "clientPackageManager": "npm",
    "clientTheme": "none",
    "clientThemeVariant": "",
    "clusteredDbApps": {},
    "creationTimestamp": 1646808904191,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "devServerPort": 9060,
    "directoryPath": "../",
    "dockerPushCommand": "docker push",
    "dockerRepositoryName": "*******",
    "dtoSuffix": "DTO",
    "enableGradleEnterprise": false,
    "enableHibernateCache": true,
    "enableSwaggerCodegen": false,
    "enableTranslation": false,
    "entities": [
      "AzUser",
      "Post",
      "Comment",
      "ParentChildComment",
      "PostAttribute"
    ],
    "entitySuffix": "",
    "incrementalChangelog": true,
    "ingressDomain": "something.something.com",
    "ingressType": "nginx",
    "istio": false,
    "jhiPrefix": "jhi",
    "jhipsterVersion": "7.8.1",
    "jwtSecretKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons",
    "kubernetesNamespace": "jhipster_app",
    "kubernetesServiceType": "Ingress",
    "languages": ["en", "fr"],
    "lastLiquibaseTimestamp": 1652177864000,
    "messageBroker": false,
    "monitoring": "no",
    "nativeLanguage": "en",
    "otherModules": [],
    "packageName": "com.test.test.jhipster_app",
    "pages": [],
    "prodDatabaseType": "mysql",
    "reactive": false,
    "searchEngine": false,
    "serverPort": "8080",
    "serverSideOptions": [],
    "serviceDiscoveryType": false,
    "skipCheckLengthOfIdentifier": false,
    "skipFakeData": false,
    "skipUserManagement": false,
    "testFrameworks": [],
    "websocket": false,
    "withAdminUi": true
  }
}

</pre>
</details>

##### **JDL for the Entity configuration(s) `entityName.json` files generated in the `.jhipster` directory**

<details>
<summary>JDL entity definitions</summary>

<pre>
entity AzUser {
  userGuid String required
  firstName String required
  lastName String required
  email String required pattern(/^[^@\s]+@[^@\s]+\.[^@\s]+$/)
}
entity Post {
  post String required
  description TextBlob required
  createdTime ZonedDateTime required
  updatedTime ZonedDateTime required
  entityId Integer
  viewCounter Integer
}
entity Comment {
  comment String required
  createdTime ZonedDateTime required
  updatedTime ZonedDateTime required
}
entity ParentChildComment {
  parentCommentId Integer required
  childCommentId Integer required
}
entity PostAttribute {
  userId Integer required
  userName String required
 }

relationship OneToMany {
  AzUser{post required} to Post{azUser required}
  AzUser{comment required} to Comment{azUser required}
  Post{comment required} to Comment{post required}
  Post{postAttribute required} to PostAttribute{post required}
}

dto AzUser, Post, Comment, ParentChildComment, PostAttribute with mapstruct
paginate AzUser, Post, Comment, ParentChildComment, PostAttribute with pagination
service AzUser, Post, Comment, ParentChildComment, PostAttribute with serviceClass
filter AzUser, Post, Comment, ParentChildComment, PostAttribute

</pre>
</details>

##### **Environment and Tools**

openjdk version "17.0.2" 2022-01-18
OpenJDK Runtime Environment Homebrew (build 17.0.2+0)
OpenJDK 64-Bit Server VM Homebrew (build 17.0.2+0, mixed mode, sharing)

git version 2.32.0 (Apple Git-132)

node: v17.6.0

npm: 8.5.1

Docker version 20.10.9, build c2ea9bc

No change to package.json was detected. No package manager install will be executed.
Congratulations, JHipster execution is complete!
Sponsored with ❤️  by @oktadev.
Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL definitions
@dto(mapstruct)
entity AzUser(az_user) {
    @fieldNameAsDatabaseColumn(user_guid)
    userGuid String required
    @fieldNameAsDatabaseColumn(first_name)
    firstName String required
    @fieldNameAsDatabaseColumn(last_name)
    lastName String required
    email String required pattern(/^[^@\s]+@[^@\s]+\.[^@\s]+$/)
    status UserStatus required
}
@dto(mapstruct)
entity Post(post){
    post String required
    description TextBlob required
    @fieldNameAsDatabaseColumn(created_time)
    createdTime ZonedDateTime required
    @fieldNameAsDatabaseColumn(updated_time)
    updatedTime ZonedDateTime required
    entityType EntityType required
    @fieldNameAsDatabaseColumn(entity_id)
    entityId Integer 
    @fieldNameAsDatabaseColumn(view_counter)
    viewCounter Integer

}
@dto(mapstruct)
entity Comment(comment){
    comment String required
    @fieldNameAsDatabaseColumn(created_time)
    createdTime ZonedDateTime required
    @fieldNameAsDatabaseColumn(updated_time)
    updatedTime ZonedDateTime required
}
@dto(mapstruct)
entity ParentChildComment(parent_child_comment){
    @fieldNameAsDatabaseColumn(parent_comment_id)
    parentCommentId Integer required
    @fieldNameAsDatabaseColumn(child_comment_id)
    childCommentId Integer required
}
@dto(mapstruct)
entity PostAttribute(post_attribute){
    @fieldNameAsDatabaseColumn(user_id)
    userId Integer required
    @fieldNameAsDatabaseColumn(user_name)
    userName String required
    postAttributeType PostAttributeType required
}
relationship ManyToOne {
    Post{azUser required} to AzUser{post required}
    Comment{azUser required} to AzUser{comment required}
    Comment{post required} to Post{comment required}
    PostAttribute{post required} to Post{postAttribute required}
}
service * with serviceClass
paginate * with pagination
filter *
  
Browsers and Operating System

MacOS 12.3.1. Issue is not browser specific.

tejaswibm-roposo commented 2 years ago

Kindly note : I have redacted few details in the configurations above.

DanielFran commented 2 years ago

@tejaswibm-roposo Can you confirm this is related with the same issue from https://github.com/jhipster/generator-jhipster/issues/18729?

tejaswibm-roposo commented 2 years ago

@DanielFran - I doubt its the same issue. The issue here is the way the mapperImpl are getting generated whose behaviour has changed from v7.7.0 to v7.8.1. Attaching snippets for an entity generated using the schema mentioned in the bug in both versions -

  1. v7.8.1
package com.inmobi.glance.brolly.service.mapper;

import com.inmobi.glance.brolly.domain.Post;
import com.inmobi.glance.brolly.service.dto.PostDTO;
import org.mapstruct.*;

/**
 * Mapper for the entity {@link Post} and its DTO {@link PostDTO}.
 */
@Mapper(componentModel = "spring", uses = { AzUserMapper.class, PostAttributeMapper.class, CommentMapper.class })
public interface PostMapper extends EntityMapper<PostDTO, Post> {
    @Mapping(target = "azUser", source = "azUser")
    @Mapping(target = "postAttributes", source = "postAttributes")
    @Mapping(target = "comments", source = "comments")
    PostDTO toDto(Post s);

    @Named("id")
    @BeanMapping(ignoreByDefault = true)
    @Mapping(target = "id", source = "id")
    PostDTO toDtoId(Post post);
}

=======================================================================================================================

package com.inmobi.glance.brolly.service.mapper;

import com.inmobi.glance.brolly.domain.Comment;
import com.inmobi.glance.brolly.domain.Post;
import com.inmobi.glance.brolly.domain.PostAttribute;
import com.inmobi.glance.brolly.service.dto.PostAttributeDTO;
import com.inmobi.glance.brolly.service.dto.PostDTO;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.annotation.processing.Generated;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Generated(
    value = "org.mapstruct.ap.MappingProcessor",
    date = "2022-06-22T15:18:03+0530",
    comments = "version: 1.4.2.Final, compiler: Eclipse JDT (IDE) 1.4.100.v20220318-0906, environment: Java 17.0.3 (Eclipse Adoptium)"
)
@Component
public class PostMapperImpl implements PostMapper {

    @Autowired
    private AzUserMapper azUserMapper;
    @Autowired
    private PostAttributeMapper postAttributeMapper;

    @Override
    public Post toEntity(PostDTO dto) {
        if ( dto == null ) {
            return null;
        }

        Post post = new Post();

        post.setId( dto.getId() );
        post.setPost( dto.getPost() );
        post.setDescription( dto.getDescription() );
        post.setCreatedTime( dto.getCreatedTime() );
        post.setUpdatedTime( dto.getUpdatedTime() );
        post.setEntityType( dto.getEntityType() );
        post.setEntityId( dto.getEntityId() );
        post.setViewCounter( dto.getViewCounter() );
        post.azUser( azUserMapper.toEntity( dto.getAzUser() ) );
        Set<Comment> set = dto.getComments();
        if ( set != null ) {
            post.comments( new HashSet<Comment>( set ) );
        }
        post.postAttributes( postAttributeDTOSetToPostAttributeSet( dto.getPostAttributes() ) );

        return post;
    }

    @Override
    public List<Post> toEntity(List<PostDTO> dtoList) {
        if ( dtoList == null ) {
            return null;
        }

        List<Post> list = new ArrayList<Post>( dtoList.size() );
        for ( PostDTO postDTO : dtoList ) {
            list.add( toEntity( postDTO ) );
        }

        return list;
    }

    @Override
    public List<PostDTO> toDto(List<Post> entityList) {
        if ( entityList == null ) {
            return null;
        }

        List<PostDTO> list = new ArrayList<PostDTO>( entityList.size() );
        for ( Post post : entityList ) {
            list.add( toDto( post ) );
        }

        return list;
    }

    @Override
    public void partialUpdate(Post entity, PostDTO dto) {
        if ( dto == null ) {
            return;
        }

        if ( dto.getId() != null ) {
            entity.setId( dto.getId() );
        }
        if ( dto.getPost() != null ) {
            entity.setPost( dto.getPost() );
        }
        if ( dto.getDescription() != null ) {
            entity.setDescription( dto.getDescription() );
        }
        if ( dto.getCreatedTime() != null ) {
            entity.setCreatedTime( dto.getCreatedTime() );
        }
        if ( dto.getUpdatedTime() != null ) {
            entity.setUpdatedTime( dto.getUpdatedTime() );
        }
        if ( dto.getEntityType() != null ) {
            entity.setEntityType( dto.getEntityType() );
        }
        if ( dto.getEntityId() != null ) {
            entity.setEntityId( dto.getEntityId() );
        }
        if ( dto.getViewCounter() != null ) {
            entity.setViewCounter( dto.getViewCounter() );
        }
        if ( dto.getAzUser() != null ) {
            entity.azUser( azUserMapper.toEntity( dto.getAzUser() ) );
        }
        if ( entity.getComments() != null ) {
            Set<Comment> set = dto.getComments();
            if ( set != null ) {
                entity.getComments().clear();
                entity.getComments().addAll( set );
            }
        }
        else {
            Set<Comment> set = dto.getComments();
            if ( set != null ) {
                entity.comments( new HashSet<Comment>( set ) );
            }
        }
        if ( entity.getPostAttributes() != null ) {
            Set<PostAttribute> set1 = postAttributeDTOSetToPostAttributeSet( dto.getPostAttributes() );
            if ( set1 != null ) {
                entity.getPostAttributes().clear();
                entity.getPostAttributes().addAll( set1 );
            }
        }
        else {
            Set<PostAttribute> set1 = postAttributeDTOSetToPostAttributeSet( dto.getPostAttributes() );
            if ( set1 != null ) {
                entity.postAttributes( set1 );
            }
        }
    }

    @Override
    public PostDTO toDto(Post s) {
        if ( s == null ) {
            return null;
        }

        PostDTO postDTO = new PostDTO();

        postDTO.setAzUser( azUserMapper.toDto( s.getAzUser() ) );
        postDTO.setPostAttributes( postAttributeSetToPostAttributeDTOSet( s.getPostAttributes() ) );
        Set<Comment> set1 = s.getComments();
        if ( set1 != null ) {
            postDTO.setComments( new HashSet<Comment>( set1 ) );
        }
        postDTO.setId( s.getId() );
        postDTO.setPost( s.getPost() );
        postDTO.setDescription( s.getDescription() );
        postDTO.setCreatedTime( s.getCreatedTime() );
        postDTO.setUpdatedTime( s.getUpdatedTime() );
        postDTO.setEntityType( s.getEntityType() );
        postDTO.setEntityId( s.getEntityId() );
        postDTO.setViewCounter( s.getViewCounter() );

        return postDTO;
    }

    @Override
    public PostDTO toDtoId(Post post) {
        if ( post == null ) {
            return null;
        }

        PostDTO postDTO = new PostDTO();

        postDTO.setId( post.getId() );

        return postDTO;
    }

    protected Set<PostAttribute> postAttributeDTOSetToPostAttributeSet(Set<PostAttributeDTO> set) {
        if ( set == null ) {
            return null;
        }

        Set<PostAttribute> set1 = new HashSet<PostAttribute>( Math.max( (int) ( set.size() / .75f ) + 1, 16 ) );
        for ( PostAttributeDTO postAttributeDTO : set ) {
            set1.add( postAttributeMapper.toEntity( postAttributeDTO ) );
        }

        return set1;
    }

    protected Set<PostAttributeDTO> postAttributeSetToPostAttributeDTOSet(Set<PostAttribute> set) {
        if ( set == null ) {
            return null;
        }

        Set<PostAttributeDTO> set1 = new HashSet<PostAttributeDTO>( Math.max( (int) ( set.size() / .75f ) + 1, 16 ) );
        for ( PostAttribute postAttribute : set ) {
            set1.add( postAttributeMapper.toDto( postAttribute ) );
        }

        return set1;
    }
}
  1. v7.7.0
package com.inmobi.glance.brolly.service.mapper;

import com.inmobi.glance.brolly.domain.AzUser;
import com.inmobi.glance.brolly.domain.Post;
import com.inmobi.glance.brolly.service.dto.AzUserDTO;
import com.inmobi.glance.brolly.service.dto.PostDTO;
import org.mapstruct.*;

/**
 * Mapper for the entity {@link Post} and its DTO {@link PostDTO}.
 */
@Mapper(componentModel = "spring")
public interface PostMapper extends EntityMapper<PostDTO, Post> {
    @Mapping(target = "azUser", source = "azUser", qualifiedByName = "azUserId")
    PostDTO toDto(Post s);

    @Named("azUserId")
    @BeanMapping(ignoreByDefault = true)
    @Mapping(target = "id", source = "id")
    AzUserDTO toDtoAzUserId(AzUser azUser);
}

=======================================================================================

package com.inmobi.glance.brolly.service.mapper;

import com.inmobi.glance.brolly.domain.AzUser;
import com.inmobi.glance.brolly.domain.Dashboard;
import com.inmobi.glance.brolly.domain.Doc;
import com.inmobi.glance.brolly.domain.Portal;
import com.inmobi.glance.brolly.domain.Post;
import com.inmobi.glance.brolly.domain.Schema;
import com.inmobi.glance.brolly.service.dto.AzUserDTO;
import com.inmobi.glance.brolly.service.dto.DashboardDTO;
import com.inmobi.glance.brolly.service.dto.DocDTO;
import com.inmobi.glance.brolly.service.dto.PortalDTO;
import com.inmobi.glance.brolly.service.dto.PostDTO;
import com.inmobi.glance.brolly.service.dto.SchemaDTO;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.annotation.processing.Generated;
import org.springframework.stereotype.Component;

@Generated(
    value = "org.mapstruct.ap.MappingProcessor",
    date = "2022-06-22T15:24:21+0530",
    comments = "version: 1.4.2.Final, compiler: Eclipse JDT (IDE) 1.4.100.v20220318-0906, environment: Java 17.0.3 (Eclipse Adoptium)"
)
@Component
public class PostMapperImpl implements PostMapper {

    @Override
    public Post toEntity(PostDTO dto) {
        if ( dto == null ) {
            return null;
        }

        Post post = new Post();

        post.setId( dto.getId() );
        post.setPost( dto.getPost() );
        post.setDescription( dto.getDescription() );
        post.setCreatedTime( dto.getCreatedTime() );
        post.setUpdatedTime( dto.getUpdatedTime() );
        post.setEntityType( dto.getEntityType() );
        post.setEntityId( dto.getEntityId() );
        post.setViewCounter( dto.getViewCounter() );
        post.azUser( azUserDTOToAzUser( dto.getAzUser() ) );

        return post;
    }

    @Override
    public List<Post> toEntity(List<PostDTO> dtoList) {
        if ( dtoList == null ) {
            return null;
        }

        List<Post> list = new ArrayList<Post>( dtoList.size() );
        for ( PostDTO postDTO : dtoList ) {
            list.add( toEntity( postDTO ) );
        }

        return list;
    }

    @Override
    public List<PostDTO> toDto(List<Post> entityList) {
        if ( entityList == null ) {
            return null;
        }

        List<PostDTO> list = new ArrayList<PostDTO>( entityList.size() );
        for ( Post post : entityList ) {
            list.add( toDto( post ) );
        }

        return list;
    }

    @Override
    public void partialUpdate(Post entity, PostDTO dto) {
        if ( dto == null ) {
            return;
        }

        if ( dto.getId() != null ) {
            entity.setId( dto.getId() );
        }
        if ( dto.getPost() != null ) {
            entity.setPost( dto.getPost() );
        }
        if ( dto.getDescription() != null ) {
            entity.setDescription( dto.getDescription() );
        }
        if ( dto.getCreatedTime() != null ) {
            entity.setCreatedTime( dto.getCreatedTime() );
        }
        if ( dto.getUpdatedTime() != null ) {
            entity.setUpdatedTime( dto.getUpdatedTime() );
        }
        if ( dto.getEntityType() != null ) {
            entity.setEntityType( dto.getEntityType() );
        }
        if ( dto.getEntityId() != null ) {
            entity.setEntityId( dto.getEntityId() );
        }
        if ( dto.getViewCounter() != null ) {
            entity.setViewCounter( dto.getViewCounter() );
        }
        if ( dto.getAzUser() != null ) {
            if ( entity.getAzUser() == null ) {
                entity.azUser( new AzUser() );
            }
            azUserDTOToAzUser1( dto.getAzUser(), entity.getAzUser() );
        }
    }

    @Override
    public PostDTO toDto(Post s) {
        if ( s == null ) {
            return null;
        }

        PostDTO postDTO = new PostDTO();

        postDTO.setAzUser( toDtoAzUserId( s.getAzUser() ) );
        postDTO.setId( s.getId() );
        postDTO.setPost( s.getPost() );
        postDTO.setDescription( s.getDescription() );
        postDTO.setCreatedTime( s.getCreatedTime() );
        postDTO.setUpdatedTime( s.getUpdatedTime() );
        postDTO.setEntityType( s.getEntityType() );
        postDTO.setEntityId( s.getEntityId() );
        postDTO.setViewCounter( s.getViewCounter() );

        return postDTO;
    }

    @Override
    public AzUserDTO toDtoAzUserId(AzUser azUser) {
        if ( azUser == null ) {
            return null;
        }

        AzUserDTO azUserDTO = new AzUserDTO();

        azUserDTO.setId( azUser.getId() );

        return azUserDTO;
    }

    protected Portal portalDTOToPortal(PortalDTO portalDTO) {
        if ( portalDTO == null ) {
            return null;
        }

        Portal portal = new Portal();

        portal.setId( portalDTO.getId() );
        portal.setName( portalDTO.getName() );
        portal.setUrl( portalDTO.getUrl() );
        portal.setDescription( portalDTO.getDescription() );
        portal.setOwner( portalDTO.getOwner() );
        portal.setTags( portalDTO.getTags() );
        portal.setStatus( portalDTO.getStatus() );
        portal.setUnitType( portalDTO.getUnitType() );
        portal.setWindow( portalDTO.getWindow() );
        portal.setHealth( portalDTO.getHealth() );
        portal.setComment( portalDTO.getComment() );
        portal.setIconSrc( portalDTO.getIconSrc() );

        return portal;
    }

    protected Set<Portal> portalDTOSetToPortalSet(Set<PortalDTO> set) {
        if ( set == null ) {
            return null;
        }

        Set<Portal> set1 = new HashSet<Portal>( Math.max( (int) ( set.size() / .75f ) + 1, 16 ) );
        for ( PortalDTO portalDTO : set ) {
            set1.add( portalDTOToPortal( portalDTO ) );
        }

        return set1;
    }

    protected Dashboard dashboardDTOToDashboard(DashboardDTO dashboardDTO) {
        if ( dashboardDTO == null ) {
            return null;
        }

        Dashboard dashboard = new Dashboard();

        dashboard.setId( dashboardDTO.getId() );
        dashboard.setName( dashboardDTO.getName() );
        dashboard.setUrl( dashboardDTO.getUrl() );
        dashboard.setDescription( dashboardDTO.getDescription() );
        dashboard.setOwner( dashboardDTO.getOwner() );
        dashboard.setTags( dashboardDTO.getTags() );
        dashboard.setStatus( dashboardDTO.getStatus() );
        dashboard.setUnitType( dashboardDTO.getUnitType() );
        dashboard.setWindow( dashboardDTO.getWindow() );
        dashboard.setComment( dashboardDTO.getComment() );
        dashboard.setVideoUrl( dashboardDTO.getVideoUrl() );
        dashboard.setIconSrc( dashboardDTO.getIconSrc() );
        dashboard.setViewCounter( dashboardDTO.getViewCounter() );

        return dashboard;
    }

    protected Set<Dashboard> dashboardDTOSetToDashboardSet(Set<DashboardDTO> set) {
        if ( set == null ) {
            return null;
        }

        Set<Dashboard> set1 = new HashSet<Dashboard>( Math.max( (int) ( set.size() / .75f ) + 1, 16 ) );
        for ( DashboardDTO dashboardDTO : set ) {
            set1.add( dashboardDTOToDashboard( dashboardDTO ) );
        }

        return set1;
    }

    protected Doc docDTOToDoc(DocDTO docDTO) {
        if ( docDTO == null ) {
            return null;
        }

        Doc doc = new Doc();

        doc.setId( docDTO.getId() );
        doc.setName( docDTO.getName() );
        doc.setUrl( docDTO.getUrl() );
        doc.setDescription( docDTO.getDescription() );
        doc.setOwner( docDTO.getOwner() );
        doc.setTags( docDTO.getTags() );
        doc.setStatus( docDTO.getStatus() );
        doc.setUnitType( docDTO.getUnitType() );
        doc.setWindow( docDTO.getWindow() );
        doc.setComment( docDTO.getComment() );
        doc.setIconSrc( docDTO.getIconSrc() );

        return doc;
    }

    protected Set<Doc> docDTOSetToDocSet(Set<DocDTO> set) {
        if ( set == null ) {
            return null;
        }

        Set<Doc> set1 = new HashSet<Doc>( Math.max( (int) ( set.size() / .75f ) + 1, 16 ) );
        for ( DocDTO docDTO : set ) {
            set1.add( docDTOToDoc( docDTO ) );
        }

        return set1;
    }

    protected Schema schemaDTOToSchema(SchemaDTO schemaDTO) {
        if ( schemaDTO == null ) {
            return null;
        }

        Schema schema = new Schema();

        schema.setId( schemaDTO.getId() );
        schema.setName( schemaDTO.getName() );
        schema.setUnitType( schemaDTO.getUnitType() );

        return schema;
    }

    protected Set<Schema> schemaDTOSetToSchemaSet(Set<SchemaDTO> set) {
        if ( set == null ) {
            return null;
        }

        Set<Schema> set1 = new HashSet<Schema>( Math.max( (int) ( set.size() / .75f ) + 1, 16 ) );
        for ( SchemaDTO schemaDTO : set ) {
            set1.add( schemaDTOToSchema( schemaDTO ) );
        }

        return set1;
    }

    protected AzUser azUserDTOToAzUser(AzUserDTO azUserDTO) {
        if ( azUserDTO == null ) {
            return null;
        }

        AzUser azUser = new AzUser();

        azUser.setId( azUserDTO.getId() );
        azUser.setUserGuid( azUserDTO.getUserGuid() );
        azUser.setFirstName( azUserDTO.getFirstName() );
        azUser.setLastName( azUserDTO.getLastName() );
        azUser.setEmail( azUserDTO.getEmail() );
        azUser.setStatus( azUserDTO.getStatus() );
        azUser.portals( portalDTOSetToPortalSet( azUserDTO.getPortals() ) );
        azUser.dashboards( dashboardDTOSetToDashboardSet( azUserDTO.getDashboards() ) );
        azUser.docs( docDTOSetToDocSet( azUserDTO.getDocs() ) );
        azUser.schemata( schemaDTOSetToSchemaSet( azUserDTO.getSchemata() ) );

        return azUser;
    }

    protected void azUserDTOToAzUser1(AzUserDTO azUserDTO, AzUser mappingTarget) {
        if ( azUserDTO == null ) {
            return;
        }

        if ( azUserDTO.getId() != null ) {
            mappingTarget.setId( azUserDTO.getId() );
        }
        if ( azUserDTO.getUserGuid() != null ) {
            mappingTarget.setUserGuid( azUserDTO.getUserGuid() );
        }
        if ( azUserDTO.getFirstName() != null ) {
            mappingTarget.setFirstName( azUserDTO.getFirstName() );
        }
        if ( azUserDTO.getLastName() != null ) {
            mappingTarget.setLastName( azUserDTO.getLastName() );
        }
        if ( azUserDTO.getEmail() != null ) {
            mappingTarget.setEmail( azUserDTO.getEmail() );
        }
        if ( azUserDTO.getStatus() != null ) {
            mappingTarget.setStatus( azUserDTO.getStatus() );
        }
        if ( mappingTarget.getPortals() != null ) {
            Set<Portal> set = portalDTOSetToPortalSet( azUserDTO.getPortals() );
            if ( set != null ) {
                mappingTarget.getPortals().clear();
                mappingTarget.getPortals().addAll( set );
            }
        }
        else {
            Set<Portal> set = portalDTOSetToPortalSet( azUserDTO.getPortals() );
            if ( set != null ) {
                mappingTarget.portals( set );
            }
        }
        if ( mappingTarget.getDashboards() != null ) {
            Set<Dashboard> set1 = dashboardDTOSetToDashboardSet( azUserDTO.getDashboards() );
            if ( set1 != null ) {
                mappingTarget.getDashboards().clear();
                mappingTarget.getDashboards().addAll( set1 );
            }
        }
        else {
            Set<Dashboard> set1 = dashboardDTOSetToDashboardSet( azUserDTO.getDashboards() );
            if ( set1 != null ) {
                mappingTarget.dashboards( set1 );
            }
        }
        if ( mappingTarget.getDocs() != null ) {
            Set<Doc> set2 = docDTOSetToDocSet( azUserDTO.getDocs() );
            if ( set2 != null ) {
                mappingTarget.getDocs().clear();
                mappingTarget.getDocs().addAll( set2 );
            }
        }
        else {
            Set<Doc> set2 = docDTOSetToDocSet( azUserDTO.getDocs() );
            if ( set2 != null ) {
                mappingTarget.docs( set2 );
            }
        }
        if ( mappingTarget.getSchemata() != null ) {
            Set<Schema> set3 = schemaDTOSetToSchemaSet( azUserDTO.getSchemata() );
            if ( set3 != null ) {
                mappingTarget.getSchemata().clear();
                mappingTarget.getSchemata().addAll( set3 );
            }
        }
        else {
            Set<Schema> set3 = schemaDTOSetToSchemaSet( azUserDTO.getSchemata() );
            if ( set3 != null ) {
                mappingTarget.schemata( set3 );
            }
        }
    }
}

I have upgraded JHipster already. Hence, not able to get earlier version of generated mapperImpl. Question - Why is 1-n mapping of entity not being mapped in dto and mapperImpl. Ex: PostAttributes and Comments set ? In v7.7.0, this was handled as expected.

github-actions[bot] commented 10 months ago

This issue is stale because it has been open for too long without any activity. Due to the moving nature of jhipster generated application, bugs can become invalid. If this issue still applies please comment otherwise it will be closed in 7 days

github-actions[bot] commented 9 months ago

JHipster has completed the sample check .yo-rc.json: valid Entities JDL: error Application: Frontend check: skipped Backend check: skipped E2E check: skipped

This check uses jhipster info output from the issue description to generate the sample. Bug report that does not contain this information will be marked as invalid.

mshima commented 9 months ago

Sample is missing information, cannot be reproduced. Fixes for cyclic relationships landed in https://github.com/jhipster/generator-jhipster/pull/24746. Closing.