[hibernate-issues] [Hibernate-JIRA] Created: (HBX-1048) Table names which are already "camelcase" get false

Frank Langelage (JIRA) noreply at atlassian.com
Tue Mar 11 18:05:33 EDT 2008


Table names which are already "camelcase" get false
---------------------------------------------------

                 Key: HBX-1048
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-1048
             Project: Hibernate Tools
          Issue Type: Bug
          Components: hbm2java
    Affects Versions: 3.2.0.GA
         Environment: MS SQL Server Express Edition, sun JDK 1.5.0_15 on Solaris Sparc 10
            Reporter: Frank Langelage


See http://forum.hibernate.org/viewtopic.php?p=2379127#2379127.

This small diff fixes the problem for me.
If the tablename contains at least one upper case character and one lower case character the table name is taken as it is to use as the class name.
If only lower case or only upper case characters are found, the current algorithm is used (camlecase the table name).

jboss at sb2000:/home/jboss/Hibernate svn diff HibernateExt
Index: HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DefaultReverseEngineeringStrategy.java
===================================================================
--- HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DefaultReverseEngineeringStrategy.java (revision 14422)
+++ HibernateExt/tools/src/java/org/hibernate/cfg/reveng/DefaultReverseEngineeringStrategy.java (working copy)
@@ -128,7 +128,13 @@
        public String tableToClassName(TableIdentifier tableIdentifier) {

                String pkgName = settings.getDefaultPackageName();
-               String className = toUpperCamelCase( tableIdentifier.getName() );
+               String tableName = tableIdentifier.getName();
+               String className;
+               if(tableName.matches(".*\\p{javaLowerCase}.*" ) && tableName.matches( ".*\\p{javaUpperCase}.*")) {
+                       className = tableName;
+               } else {
+                       className = toUpperCamelCase( tableName );
+               }

                if(pkgName.length()>0) {
                        return StringHelper.qualify(pkgName, className);


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list