[FIXED] Hibernate JPA 2 Metamodel Generator Turkish Char problem

Issue

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-jpamodelgen</artifactId>
        <version>6.0.0.Alpha2</version>
    </dependency>

When I add hibernate-jpamodelgen dependency to the project. Everything works properly until the compilation process. I can see generated metamodel classes under target folder. But because of my system defaults (that are related to my operating system), the field name constants on metamodel classes are converted wrong.

public static final String TRANST�ME = "transtime";
public static final String NOTE = "note";
public static final String �SACT�VE = "isactive";

[ERROR] /C:/Users/*/IdeaProjects/*/target/generated-sources/annotations/*/model/acc/InvtypeView_.java:[20,37] illegal character: '\ufffd'

And that causes a compile error. When I analyzed the code generation process I can see org.hibernate.jpamodelgen.util.StringUtil classes’ getUpperUnderscoreCaseFromLowerCamelCase method causes this.

public static String getUpperUnderscoreCaseFromLowerCamelCase(String lowerCamelCaseString){
    return lowerCamelCaseString.replaceAll("(.)(\\p{Upper})", "$1_$2").toUpperCase();
}

toUpperCase method should have parameter Locale.ROOT.

I’ve created an issue on Hibernate issue tracker system.

Any quick solution/workaround would be great.

Solution

I have fixed the same problem with following configuration.

<plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <source>${java.version}</source>
        <target>${java.version}</target>
        <fork>true</fork>
        <compilerArgs>
            <compilerArg>-J-Duser.language=en</compilerArg>
            <compilerArg>-J-Duser.country=US</compilerArg>
            <compilerArg>-J-Dfile.encoding=UTF-8</compilerArg>
        </compilerArgs>
        <annotationProcessorPaths>
            <annotationProcessorPath>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-jpamodelgen</artifactId>
                <version>${hibernate.version}</version>
            </annotationProcessorPath>
        </annotationProcessorPaths>
    </configuration>
</plugin>

Answered By – Ghokun

Answer Checked By – Dawn Plyler (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published