Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating a Job with default JDL breaks entity access #7463

Closed
agaspardcilia opened this issue Apr 10, 2018 · 8 comments
Closed

Creating a Job with default JDL breaks entity access #7463

agaspardcilia opened this issue Apr 10, 2018 · 8 comments
Milestone

Comments

@agaspardcilia
Copy link
Member

agaspardcilia commented Apr 10, 2018

Overview of the issue

When you try to create a Job entity the server will return a 500, and you won't be able to access that entity anymore.

Motivation for or Use Case

Bug with the default JDL.

Reproduce the error

Create a "vanilla" Angular project and import the default JDL provided by JDL Studio

Related issues

idk

Suggest a Fix

idk, I'll try to take a look this week.

JHipster Version(s)
test@0.0.0 /home/ippon/repos/tests/test
└── generator-jhipster@5.0.0-beta.0  -> /home/ippon/repos/generator-jhipster

JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "com.mycompany.myapp",
      "nativeLanguage": "en"
    },
    "jhipsterVersion": "5.0.0-beta.0",
    "baseName": "test",
    "reactive": false,
    "packageName": "com.mycompany.myapp",
    "packageFolder": "com/mycompany/myapp",
    "serverPort": "8080",
    "authenticationType": "jwt",
    "cacheProvider": "ehcache",
    "enableHibernateCache": true,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "mysql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": false,
    "buildTool": "maven",
    "enableSwaggerCodegen": false,
    "jwtSecretKey": "replaced-by-jhipster-info",
    "clientFramework": "angularX",
    "useSass": false,
    "clientPackageManager": "yarn",
    "applicationType": "monolith",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "enableTranslation": true,
    "nativeLanguage": "en",
    "languages": [
      "en"
    ]
  }
}
JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
entity Region (region) {
  regionName String
}
entity Country (country) {
  countryName String
}
/**
 * not an ignored comment
 */
entity Location (location) {
  streetAddress String,
  postalCode String,
  city String,
  stateProvince String
}
entity Department (department) {
  departmentName String required
}
/**
 * Task entity.
 * @author The JHipster team.
 */
entity Task (task) {
  title String,
  description String
}
/**
 * The Employee entity.
 */
entity Employee (employee) {
  /**
   * The firstname attribute.
   */
  firstName String,
  lastName String,
  email String,
  phoneNumber String,
  hireDate Instant,
  salary Long,
  commissionPct Long
}
entity Job (job) {
  jobTitle String,
  minSalary Long,
  maxSalary Long
}
entity JobHistory (job_history) {
  startDate Instant,
  endDate Instant,
  language Language
}

enum Language {
  FRENCH,
  ENGLISH,
  SPANISH
}

relationship OneToOne {
  Country{region} to Region,
  Location{country} to Country,
  Department{location} to Location,
  JobHistory{job} to Job,
  JobHistory{department} to Department,
  JobHistory{employee} to Employee
}
relationship OneToMany {
  /**
   * A relationship
   */
  Department{employee} to Employee{department},
  Employee{job} to Job{employee}
}
relationship ManyToOne {
  Employee{manager} to Employee
}
relationship ManyToMany {
  Job{task(title)} to Task{job}
}

dto Region, Country, Location, Department, Task, Employee, Job, JobHistory with mapstruct
service Region, Country, Location, Department, Task, JobHistory with serviceImpl
angularSuffix Region, Country, Location, Department, Task, Employee, Job, JobHistory with mySuffix
paginate Employee, JobHistory with infinite-scroll
paginate Job with pagination

Environment and Tools

openjdk version "1.8.0_162"
OpenJDK Runtime Environment (build 1.8.0_162-8u162-b12-0ubuntu0.16.04.2-b12)
OpenJDK 64-Bit Server VM (build 25.162-b12, mixed mode)

git version 2.7.4

node: v8.11.1

npm: 5.6.0

yeoman: 2.0.1

yarn: 1.5.1

Docker version 1.13.1, build 092cba3

docker-compose version 1.8.0, build unknown

Entity configuration(s) entityName.json files generated in the .jhipster directory
Browsers and Operating System

I don't think it matters.

@MathieuAA
Copy link
Member

MathieuAA commented Apr 10, 2018 via email

@agaspardcilia
Copy link
Member Author

@MathieuAA I meant that requesting api/getAllJob was resulting in a 500. But it should be fixed now.

@ruddell
Copy link
Member

ruddell commented Apr 10, 2018

Based on the changes from #5629 (comment) (same issue as here), we no longer allow DTOs without an entity Service or ServiceImpl. The only way this happened was by importing the JDL.

The proposed fix enables eager loading of the relationship which is a code smell (see linked issue for discussion on that). But it seems we eager load ManyToMany relationships when you use a service+DTO... Not sure what to do here.

One thing we should do is update the default JDL to remove incompatible options

@MathieuAA
Copy link
Member

MathieuAA commented Apr 10, 2018 via email

@agaspardcilia
Copy link
Member Author

Looks like it's a bit more complicated than I thought.

@jdubois
Copy link
Member

jdubois commented May 17, 2018

Indeed, using a DTO without a service is not supported anymore, and the JDL should not allow that.

On the main generator there is no problem, as you don't have that option in the prompts, and this is why I'm closing this.

@jdubois jdubois closed this as completed May 17, 2018
@MathieuAA
Copy link
Member

MathieuAA commented May 17, 2018 via email

@jdubois
Copy link
Member

jdubois commented May 17, 2018

Thanks @MathieuAA !!

@jdubois jdubois added this to the 5.0.0-beta.2 milestone Jun 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants