No restriction in back-end and front-end for default varchar(255) generated property causes database to crash
See original GitHub issue- Please follow the issue template below for bug reports and feature requests.
- Tickets opened without any of these informations will be closed without any explanation.
Overview of the issue
Hi everyone, I’m a new user of JHipster, and I have to say that this thing is absolutely insane ! It allows me to gain a lot of time. But I think I found one thing that is not handled by JHipster.
I created an entity called “event”, where the user can put a commentary. When creating the entity, I didn’t mention any restrictions for the length of this string. Then, by default I presume, this string was a VARCHAR(255) in my database (an H2 database by the way). No problems up to now.
But, when I tried to insert a new event, with a commentray of more than 255 characters, the thing began. My app got completely crazy, updated all my event and deleted all the commentray of my events, without telling me there was a problem (which is usually the case when there is, you can see the popup danger message like here:
)
So I tried to figure out what just happened to me, and I think I foudn this out.
Actually, there were no length restrictions in my front-end app. So, I went to my back-end app to see my property “Commentary” in my “event” domain, and … There was no restriction neither.
So, it actually seems that JHipster doens’t put any restrictions when you leave the default length for a String, which I think has to be fixed. That’s why I posted this.
Motivation for or Use Case
This is not like " a bug", but more like a think that is not handled by JHipster, I think, and has to be fixed because it is really annoying.
Reproduce the error
To reproduce this error, you simply have to create an entity, with a property “String” with no restrictions at all. Then, you try to add an entity of this type with the String property greater than 255. In the database (H2 for me, as I said, I don’t know if you can reproduce this thing with another database), the field will be a “VARCHAR(255)”, and there won’t be any restrictions in the backend or frontend part of your app. So you allow your users to insert more than a 255 length String, which will cause you app to completely get crazy.
Related issues
i don’t know if this bug has already been reported before. I don’t hope so, because this comment is quiet long to write.
Suggest a Fix
The fix won’t be hard to code. You should just handle the fact that if the user doesn’t choose any restriction for a String property, you should had a restriction to the Domain class in the back end like:
@Column(name = “commentary”, length = 1500) private String commentary;
and in the textarea in the front end.
JHipster Version(s)
Latest one
JHipster configuration
Welcome to the JHipster Information Sub-Generator
JHipster Version(s)
cv-manager@0.0.0 C:\Users\ddv\Desktop\CVManager 28 02 8h
+-- UNMET PEER DEPENDENCY @angular/compiler@2.4.7
+-- UNMET PEER DEPENDENCY @angular/core@2.4.7
`-- generator-jhipster@4.0.6
JHipster configuration, a .yo-rc.json
file generated in the root folder
{
"generator-jhipster": {
"jhipsterVersion": "4.0.6",
"baseName": "CVManager",
"packageName": "be.nsi.stage.recruitment",
"packageFolder": "be/nsi/stage/recruitment",
"serverPort": "8080",
"authenticationType": "jwt",
"hibernateCache": "no",
"clusteredHttpSession": false,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "h2Disk",
"prodDatabaseType": "mysql",
"searchEngine": false,
"messageBroker": false,
"serviceDiscoveryType": false,
"buildTool": "maven",
"enableSocialSignIn": false,
"jwtSecretKey": "68e8363003d03d8d36a0d841e75ecc6a48c48a2e",
"clientFramework": "angular2",
"useSass": false,
"clientPackageManager": "yarn",
"applicationType": "monolith",
"testFrameworks": [],
"jhiPrefix": "jhi",
"enableTranslation": false
}
}
Entity configuration(s) entityName.json
files generated in the .jhipster
directory
Address.json
{
"fluentMethods": true,
"relationships": [
{
"relationshipType": "many-to-one",
"relationshipName": "locality",
"otherEntityName": "locality",
"otherEntityField": "name"
},
{
"relationshipType": "many-to-one",
"relationshipName": "country",
"otherEntityName": "country",
"otherEntityField": "name"
}
],
"fields": [
{
"fieldName": "houseNumber",
"fieldType": "Integer"
},
{
"fieldName": "postBoxNumber",
"fieldType": "String"
},
{
"fieldName": "street",
"fieldType": "String"
},
{
"fieldName": "foreignLocality",
"fieldType": "String"
},
{
"fieldName": "foreignCp",
"fieldType": "Integer"
}
],
"changelogDate": "20170228072815",
"entityTableName": "address",
"dto": "no",
"pagination": "no",
"service": "no"
}
Candidate.json
{
"fluentMethods": true,
"relationships": [
{
"relationshipType": "one-to-one",
"relationshipName": "salaryPackage",
"otherEntityName": "salaryPackage",
"otherEntityField": "id",
"ownerSide": true,
"otherEntityRelationshipName": "candidate"
},
{
"relationshipType": "one-to-one",
"relationshipName": "address",
"otherEntityName": "address",
"otherEntityField": "street",
"ownerSide": true,
"otherEntityRelationshipName": "candidate"
},
{
"relationshipType": "one-to-many",
"relationshipName": "documents",
"otherEntityName": "document",
"otherEntityRelationshipName": "candidate"
},
{
"relationshipType": "one-to-many",
"relationshipName": "events",
"otherEntityName": "event",
"otherEntityRelationshipName": "candidate"
},
{
"relationshipType": "many-to-one",
"relationshipName": "recruitmentStatus",
"otherEntityName": "recruitmentStatus",
"otherEntityField": "name"
},
{
"relationshipType": "many-to-one",
"relationshipName": "certificate",
"otherEntityName": "certificate",
"otherEntityField": "name"
},
{
"relationshipType": "many-to-many",
"otherEntityRelationshipName": "candidates",
"relationshipName": "profile",
"otherEntityName": "profileTag",
"otherEntityField": "name",
"ownerSide": true
},
{
"relationshipType": "many-to-many",
"otherEntityRelationshipName": "candidates",
"relationshipName": "techno",
"otherEntityName": "technoTag",
"otherEntityField": "name",
"ownerSide": true
},
{
"relationshipType": "many-to-many",
"otherEntityRelationshipName": "candidates",
"relationshipName": "language",
"otherEntityName": "languageTag",
"otherEntityField": "name",
"ownerSide": true
}
],
"fields": [
{
"fieldName": "lastName",
"fieldType": "String"
},
{
"fieldName": "firstName",
"fieldType": "String"
},
{
"fieldName": "phoneNumber",
"fieldType": "String"
},
{
"fieldName": "mail",
"fieldType": "String"
},
{
"fieldName": "birthDate",
"fieldType": "LocalDate"
},
{
"fieldName": "image",
"fieldType": "byte[]",
"fieldTypeBlobContent": "image"
},
{
"fieldName": "insertDate",
"fieldType": "LocalDate"
},
{
"fieldName": "linkedInURL",
"fieldType": "String"
},
{
"fieldName": "disponibilityDate",
"fieldType": "LocalDate"
}
],
"changelogDate": "20170228072815",
"entityTableName": "candidate",
"dto": "no",
"pagination": "no",
"service": "no"
}
Certificate.json
{
"fluentMethods": true,
"relationships": [
{
"relationshipType": "one-to-many",
"relationshipName": "candidates",
"otherEntityName": "candidate",
"otherEntityRelationshipName": "certificate"
}
],
"fields": [
{
"fieldName": "name",
"fieldType": "String"
}
],
"changelogDate": "20170228072815",
"entityTableName": "certificate",
"dto": "no",
"pagination": "no",
"service": "no"
}
Country.json
{
"fluentMethods": true,
"relationships": [],
"fields": [
{
"fieldName": "name",
"fieldType": "String"
}
],
"changelogDate": "20170228072815",
"entityTableName": "country",
"dto": "no",
"pagination": "no",
"service": "no"
}
Document.json
{
"fluentMethods": true,
"relationships": [
{
"relationshipName": "candidate",
"otherEntityName": "candidate",
"relationshipType": "many-to-one",
"otherEntityField": "id"
}
],
"fields": [
{
"fieldName": "uuid",
"fieldType": "String"
},
{
"fieldName": "name",
"fieldType": "String"
},
{
"fieldName": "date",
"fieldType": "LocalDate"
},
{
"fieldName": "confidentiality",
"fieldType": "Boolean"
},
{
"fieldName": "commentary",
"fieldType": "String"
}
],
"changelogDate": "20170228072815",
"entityTableName": "document",
"dto": "no",
"pagination": "no",
"service": "no"
}
Event.json
{
"fluentMethods": true,
"relationships": [
{
"relationshipName": "candidate",
"otherEntityName": "candidate",
"relationshipType": "many-to-one",
"otherEntityField": "id"
},
{
"relationshipType": "many-to-one",
"relationshipName": "eventType",
"otherEntityName": "eventType",
"otherEntityField": "name"
}
],
"fields": [
{
"fieldName": "date",
"fieldType": "LocalDate"
},
{
"fieldName": "evaluation",
"fieldType": "Integer"
},
{
"fieldName": "commentary",
"fieldType": "String"
},
{
"fieldName": "confidentiality",
"fieldType": "Boolean"
}
],
"changelogDate": "20170228072815",
"entityTableName": "event",
"dto": "no",
"pagination": "no",
"service": "no"
}
EventType.json
{
"fluentMethods": true,
"relationships": [],
"fields": [
{
"fieldName": "name",
"fieldType": "String"
}
],
"changelogDate": "20170228072815",
"entityTableName": "event_type",
"dto": "no",
"pagination": "no",
"service": "no"
}
LanguageTag.json
{
"fluentMethods": true,
"relationships": [
{
"relationshipType": "many-to-many",
"relationshipName": "candidates",
"otherEntityName": "candidate",
"ownerSide": false,
"otherEntityRelationshipName": "language"
}
],
"fields": [
{
"fieldName": "name",
"fieldType": "String"
}
],
"changelogDate": "20170228072815",
"entityTableName": "language_tag",
"dto": "no",
"pagination": "no",
"service": "no"
}
Locality.json
{
"fluentMethods": true,
"relationships": [
{
"relationshipType": "many-to-one",
"relationshipName": "country",
"otherEntityName": "country",
"otherEntityField": "name"
}
],
"fields": [
{
"fieldName": "name",
"fieldType": "String"
},
{
"fieldName": "cp",
"fieldType": "Integer"
}
],
"changelogDate": "20170228072815",
"entityTableName": "locality",
"dto": "no",
"pagination": "no",
"service": "no"
}
ProfileTag.json
{
"fluentMethods": true,
"relationships": [
{
"relationshipType": "many-to-many",
"relationshipName": "candidates",
"otherEntityName": "candidate",
"ownerSide": false,
"otherEntityRelationshipName": "profile"
}
],
"fields": [
{
"fieldName": "name",
"fieldType": "String"
}
],
"changelogDate": "20170228072815",
"entityTableName": "profile_tag",
"dto": "no",
"pagination": "no",
"service": "no"
}
RecruitmentStatus.json
{
"fluentMethods": true,
"relationships": [
{
"relationshipType": "one-to-many",
"relationshipName": "candidates",
"otherEntityName": "candidate",
"otherEntityRelationshipName": "recruitmentStatus"
}
],
"fields": [
{
"fieldName": "name",
"fieldType": "String"
}
],
"changelogDate": "20170228072815",
"entityTableName": "recruitment_status",
"dto": "no",
"pagination": "no",
"service": "no"
}
SalaryPackage.json
{
"fluentMethods": true,
"relationships": [
{
"relationshipType": "many-to-one",
"relationshipName": "salaryStatus",
"otherEntityName": "salaryStatus",
"otherEntityField": "name"
}
],
"fields": [
{
"fieldName": "mealVoucher",
"fieldType": "Boolean"
},
{
"fieldName": "groupInsurance",
"fieldType": "Boolean"
},
{
"fieldName": "healthInsurance",
"fieldType": "Boolean"
},
{
"fieldName": "car",
"fieldType": "Boolean"
},
{
"fieldName": "phone",
"fieldType": "Boolean"
},
{
"fieldName": "internet",
"fieldType": "Boolean"
},
{
"fieldName": "fuelCard",
"fieldType": "Boolean"
},
{
"fieldName": "professionalCost",
"fieldType": "Boolean"
},
{
"fieldName": "commentary",
"fieldType": "String"
},
{
"fieldName": "monthlySalary",
"fieldType": "Float"
}
],
"changelogDate": "20170228072815",
"entityTableName": "salary_package",
"dto": "no",
"pagination": "no",
"service": "no"
}
SalaryStatus.json
{
"fluentMethods": true,
"relationships": [],
"fields": [
{
"fieldName": "name",
"fieldType": "String"
}
],
"changelogDate": "20170228072815",
"entityTableName": "salary_status",
"dto": "no",
"pagination": "no",
"service": "no"
}
TechnoTag.json
{
"fluentMethods": true,
"relationships": [
{
"relationshipType": "many-to-many",
"relationshipName": "candidates",
"otherEntityName": "candidate",
"ownerSide": false,
"otherEntityRelationshipName": "techno"
}
],
"fields": [
{
"fieldName": "name",
"fieldType": "String"
}
],
"changelogDate": "20170228072815",
"entityTableName": "techno_tag",
"dto": "no",
"pagination": "no",
"service": "no"
}
Browsers and Operating System
java version “1.8.0_121” Java™ SE Runtime Environment (build 1.8.0_121-b13) Java HotSpot™ 64-Bit Server VM (build 25.121-b13, mixed mode)
node: v7.5.0
npm: 4.1.2
bower: 1.8.0
yeoman: 1.8.5
yarn: 0.20.3
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (5 by maintainers)
Sorry for that … Hope this is good now.
I feel that this is very complex to do properly, and I’m not even sure this is possible to do, as again I think the default database values can be modified by DBAs. At the moment we follow the “usual” JHipster guidelines: if you don’t do anything, you will have the default configuration of the underlying technology, and then you need to know how it works. I totally agree we could help people, and give better validation, but here that looks like a lot of work.