[hibernate-issues] [JIRA] (HBX-2014) HBM2Java uses default plattform encoding for source generation

Jordi Hernández (JIRA) jira at hibernate.atlassian.net
Sun Apr 12 16:08:48 EDT 2020


Jordi Hernández ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A8b2d9ba9-0164-469f-9b41-4c27ade9ba4e ) *created* an issue

Hibernate Tools ( https://hibernate.atlassian.net/browse/HBX?atlOrigin=eyJpIjoiMzQzNDdiNGYwMmMwNDE4Yzg0Mzg4OTgzY2M0OGViYWQiLCJwIjoiaiJ9 ) / Improvement ( https://hibernate.atlassian.net/browse/HBX-2014?atlOrigin=eyJpIjoiMzQzNDdiNGYwMmMwNDE4Yzg0Mzg4OTgzY2M0OGViYWQiLCJwIjoiaiJ9 ) HBX-2014 ( https://hibernate.atlassian.net/browse/HBX-2014?atlOrigin=eyJpIjoiMzQzNDdiNGYwMmMwNDE4Yzg0Mzg4OTgzY2M0OGViYWQiLCJwIjoiaiJ9 ) HBM2Java uses default plattform encoding for source generation ( https://hibernate.atlassian.net/browse/HBX-2014?atlOrigin=eyJpIjoiMzQzNDdiNGYwMmMwNDE4Yzg0Mzg4OTgzY2M0OGViYWQiLCJwIjoiaiJ9 )

Issue Type: Improvement Affects Versions: 5.4.13.Final Assignee: Koen Aers ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A926ec7e6-0515-4337-a65b-32fd943f79ca ) Components: hbm2java Created: 12/Apr/2020 13:08 PM Priority: Minor Reporter: Jordi Hernández ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%3A8b2d9ba9-0164-469f-9b41-4c27ade9ba4e )

I am using hbm2java via Maven integration in a project where we are doing database first development. I have used a custom ReverseEngineeringStrategy in order to import the comments from tables and fields into the generated classes.

The project language is spanish, so usually the comments in the database will contain characters with accents (á, é, í…) etc. When the code is generated, it will produce errors because the files have the wrong encoding and these characters are mangled.

I took a look at the hbm2x sources and turns out that the code that does the actual writing of the files looks as follows (in the class org.hibernate.tool.hbm2x.TemplateProducer) :

fileWriter = new FileWriter(destination);
fileWriter.write(tempResult);

The ‘destination’ variable is a File reference, and tempResult is the templates output.

Well, turns out that with this code, java will write the file using the default plattform encoding, which in my case, being a Windows user, will end up being CP-1512.

So, for international character codes support I think this code should at least write UTF-8, or even better, let the user select the encoding.

( https://hibernate.atlassian.net/browse/HBX-2014#add-comment?atlOrigin=eyJpIjoiMzQzNDdiNGYwMmMwNDE4Yzg0Mzg4OTgzY2M0OGViYWQiLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HBX-2014#add-comment?atlOrigin=eyJpIjoiMzQzNDdiNGYwMmMwNDE4Yzg0Mzg4OTgzY2M0OGViYWQiLCJwIjoiaiJ9 )

Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100124- sha1:185bad4 )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200412/c21f8678/attachment.html 


More information about the hibernate-issues mailing list