generator-jhipster: Bad value for type long with TextBlob in PostgreSQL
Overview of the issue
When using TextBlob with PostgreSQL I get an bad value for type long when finding all the records.
Motivation for or Use Case
For what I’ve read [1][2] it looks like it’s a well-known bug with Hibernate and Postgres. When having a TextBlog, Postgres uses a texttype. And then PostgreSQL connector tries to interprete the textual content as a long integer.
Reproduce the error
Take the following JDL and generate an application with Postgresql
entity Speaker {
bio TextBlob,
qualifications TextBlob,
company String,
}
- If you now log on the generated app and browse the entity Speaker, it works fine.
- Insert data to the database
INSERT INTO public.speaker(
id, bio, qualifications, company)
VALUES (1, 'lol', 'cat', 'dog');
- Browse the entity Speaker again, it breaks with a
bad value for type long.
Related issues
- [1] - https://shred.zone/cilla/page/299/string-lobs-on-postgresql-with-hibernate-36.html
- [2] - https://stackoverflow.com/questions/12647755/bad-value-for-type-long-postgresql-hibernate-spring
- [3] - https://github.com/jhipster/generator-jhipster/issues/1940
Suggest a Fix
To make it work with Postgresql, it’s just a matter of adding @Type(type = "org.hibernate.type.TextType") to the Entity Speaker (but I don’t know if this works with other SQL databases) :
@Lob
@Type(type = "org.hibernate.type.TextType")
@Column(name = "bio")
private String bio;
@Lob
@Type(type = "org.hibernate.type.TextType")
@Column(name = "qualifications")
private String qualifications;
JHipster Version(s)
cfp@0.0.0 /Users/agoncal/Documents/Code/Temp/jhipster/jhitest
└── generator-jhipster@4.5.6
JHipster configuration, a .yo-rc.json file generated in the root folder
{
"generator-jhipster": {
"promptValues": {
"packageName": "com.confinabox.cfp",
"nativeLanguage": "en"
},
"jhipsterVersion": "4.5.6",
"baseName": "cfp",
"packageName": "com.confinabox.cfp",
"packageFolder": "com/confinabox/cfp",
"serverPort": "8080",
"authenticationType": "jwt",
"hibernateCache": "ehcache",
"clusteredHttpSession": false,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "postgresql",
"prodDatabaseType": "postgresql",
"searchEngine": false,
"messageBroker": false,
"serviceDiscoveryType": false,
"buildTool": "maven",
"enableSocialSignIn": false,
"jwtSecretKey": "72323b9c0ce722f77d855cfd12224fc33d8d36b0",
"clientFramework": "angular2",
"useSass": false,
"clientPackageManager": "yarn",
"applicationType": "monolith",
"testFrameworks": [],
"jhiPrefix": "jhi",
"enableTranslation": true,
"nativeLanguage": "en",
"languages": [
"en",
"fr"
]
}
}
Entity configuration(s) entityName.json files generated in the .jhipster directory
Speaker.json
{
"fluentMethods": true,
"relationships": [],
"fields": [
{
"fieldName": "bio",
"fieldType": "byte[]",
"fieldTypeBlobContent": "text"
},
{
"fieldName": "qualifications",
"fieldType": "byte[]",
"fieldTypeBlobContent": "text"
},
{
"fieldName": "company",
"fieldType": "String"
}
],
"changelogDate": "20170627103128",
"entityTableName": "speaker",
"dto": "no",
"pagination": "no",
"service": "no"
}
Browsers and Operating System
java version “1.8.0_131” Java™ SE Runtime Environment (build 1.8.0_131-b11) Java HotSpot™ 64-Bit Server VM (build 25.131-b11, mixed mode)
git version 2.13.1
node: v8.1.1
npm: 5.0.3
bower: 1.8.0
gulp: [12:47:41] CLI version 1.3.0
yeoman: 2.0.0
yarn: 0.24.6
Docker version 17.06.0-ce-rc5, build b7e4173
docker-compose version 1.14.0, build c7bdf9e
Execution complete
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 17 (14 by maintainers)
Links to this issue
Commits related to this issue
- Add fix for Hibernate issue with TextBlob. See https://github.com/jhipster/generator-jhipster/issues/5995. — committed to ow2-proactive/scheduling by ghsioux 6 years ago
We still get the error with JHipster release v8.2.1 and postgres:14.2 to removing @Lob from your domain object fixes the problem( which is not so conventional )