generator-jhipster icon indicating copy to clipboard operation
generator-jhipster copied to clipboard

Mixing dto with non-dto entities results in error

Open vw98075 opened this issue 4 years ago • 5 comments

Overview of the issue

A simple JDL file with two entities. One of them, A, has DTO and the other one, B, doesn't. The A and B have a many-to-one relationship. The generated code won't comply due to code errors.

.../service/dto/ADTO.java:35: error: cannot find symbol
    private BDTO repo;
            ^
  symbol:   class BDTO
  location: class ADTO
.../service/dto/ADTO.java:87: error: cannot find symbol
    public BDTO getRepo() {
           ^
  symbol:   class BDTO
  location: class ADTO
.../service/dto/ADTO.java:91: error: cannot find symbol
    public void seB(BDTO repo) {
                        ^
  symbol:   class BDTO
  location: class JobCandidateRepoDTO
.../service/mapper/AMapper.java:10: error: cannot find symbol
@Mapper(componentModel = "spring", uses = { BMapper.class, UserMapper.class })
                                            ^
  symbol: class BMapper
.../service/mapper/Apper.java:11: error: No implementation was created for Aapper due to having a problem in the erroneous element null. Hint: this often means that some other annotation processor was supposed to process the erroneous element. You can also enable MapStruct verbose mode by setting -Amapstruct.verbose=true as a compilation argument.
public interface AMapper extends EntityMapper<ADTO,A {
       ^
Motivation for or Use Case
Reproduce the error
Related issues
Suggest a Fix
JHipster Version(s)
JHipster configuration
{
  "generator-jhipster": {
    "applicationType": "monolith",
    "baseName": "myapp",
    "jhipsterVersion": "7.1.0",
    "skipClient": false,
    "skipServer": false,
    "skipUserManagement": false,
    "skipCheckLengthOfIdentifier": false,
    "skipFakeData": false,
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "testFrameworks": ["cypress", "gatling"],
    "blueprints": [],
    "otherModules": [],
    "pages": [],
    "creationTimestamp": 1625095262715,
    "serviceDiscoveryType": false,
    "reactive": false,
    "authenticationType": "jwt",
    "packageName": "com.abc.myapp",
    "serverPort": "8080",
    "cacheProvider": "ehcache",
    "enableHibernateCache": true,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "postgresql",
    "buildTool": "gradle",
    "serverSideOptions": [],
    "websocket": false,
    "searchEngine": false,
    "messageBroker": false,
    "enableSwaggerCodegen": false,
    "clientFramework": "vue",
    "withAdminUi": true,
    "clientTheme": "cosmo",
    "clientThemeVariant": "primary",
    "enableTranslation": true,
    "nativeLanguage": "en",
    "packageFolder": "com/abc/myapp",
    "jwtSecretKey": "NThkZDg5YjE3OTkxNGU2YjUzNjAwODMwZjY4ODRiYmIyOWVkN2Q0NmZhMjZhNDU4MmQyYTQ5NDcxOWZlODRjY2ZhYWE5NjNjZWJkZDUyYzljYTU0NmU0OGExZDY4N2EwZjljZWQwMTliYWU3NGZiZTQ3NDQ1MGIwOTNjZDU3NmE=",
    "devServerPort": 9060,
    "clientPackageManager": "npm",
    "languages": ["en", "es"]
  }
}
Entity configuration(s) entityName.json files generated in the .jhipster directory
entity A {

    email  String required minlength(6) maxlength(255) unique pattern(/^[^@\s]+@[^@\s]+\.[^@\s]+$/), 
    createdTime Instant  required
}

entity B {
    
    name String required
   
}

relationship ManyToOne {
  	A{b(name)} to B
   	A{creator(login)} to User
}

// Set pagination options
paginate B with infinite-scroll
paginate A with pagination

// Use Data Transfer Objects (DTO)
 dto A with mapstruct

// Set service options to all except few
service A with serviceClass
Browsers and Operating System
  • [ ] Checking this box is mandatory (this is just to show you read everything)

vw98075 avatar Aug 03 '21 01:08 vw98075

OK but does it make sense? Maybe it should be prevented to define relationships between entities if they don't use same DTO options.

gmarziou avatar Aug 03 '21 08:08 gmarziou

I can see your point. I also prefer that the entity doesn't have a service class because there isn't any business logic for the entity. To my observation, a service class will be created for an entity with DTO regardless of your choice in the service class.

vw98075 avatar Aug 03 '21 21:08 vw98075

This issue is stale because it has been open 30 days with no activity. Our core developers tend to be more verbose on denying. If there is no negative comment, possibly this feature will be accepted. We are accepting PRs :smiley:. Comment or this will be closed in 7 days

github-actions[bot] avatar Sep 03 '21 00:09 github-actions[bot]

We should just restrict using mix of DTO/NoDTO entities

deepu105 avatar Apr 11 '22 10:04 deepu105

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] avatar Jan 30 '24 00:01 github-actions[bot]