[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-7198) SQLServer2005Dialect.getLimitString turns tablenames to lowercase -> SQLGrammarException: when mapping tables with capital letters

Guenther Demetz (JIRA) noreply at atlassian.com
Fri Apr 13 08:25:49 EDT 2012


    [ https://hibernate.onjira.com/browse/HHH-7198?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=46275#comment-46275 ] 

Guenther Demetz commented on HHH-7198:
--------------------------------------

Pull request: 

https://github.com/pb00067/hibernate-orm/commit/b020788a05e4ee32bc2c7b59cc64a6404cb4b716

I tested it manually with sucess on my hibernate-SQLServer2008 environment.
Don't know how to test it within the hibernate matrix tests.

Here a sample of the correct build (case sensitive !!) sql due the patch:

{code}
//createQuery("from BasicTypes").setFirstResult(3).setMaxResults(5).list();


WITH query AS (select
        basictypes0_.OID as OID3_,
        basictypes0_.OPTLOCK as OPTLOCK3_,
        basictypes0_.fieldChar as fieldChar3_,
        basictypes0_.fieldDouble as fieldDou9_3_,
        basictypes0_.fieldFloat as fieldFloat3_,
        basictypes0_.fieldLong as fieldLong3_,
        basictypes0_.fieldLongLong as fieldLo12_3_,
        basictypes0_.fieldOctet as fieldOctet3_,
        basictypes0_.fieldShort as fieldShort3_,
        basictypes0_.fieldString as fieldSt15_3_,
        basictypes0_.DTYPE as DTYPE3_,
        ROW_NUMBER() OVER (
    ORDER BY
        CURRENT_TIMESTAMP) as __hibernate_row_nr__ 
    from
        BasicTypes basictypes0_ 
    where
        basictypes0_.DTYPE in ('ConcreteSubclass', 'ConcreteClass')) SELECT
        * 
    FROM
        query 
    WHERE
        __hibernate_row_nr__ >= 4 
        AND __hibernate_row_nr__ < 9  
{code}



> SQLServer2005Dialect.getLimitString turns tablenames to lowercase ->  SQLGrammarException: when mapping tables with capital letters
> -----------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HHH-7198
>                 URL: https://hibernate.onjira.com/browse/HHH-7198
>             Project: Hibernate ORM
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 4.1.1
>         Environment: Hibernate4, SQLServer2008
>            Reporter: Guenther Demetz
>            Priority: Minor
>              Labels: pagination
>
> Usually when annotating entity classes without the @Table.name attribute, then the default mapped tablenames begin with a capital letter.
> When using the paging feature, SQLServer2005Dialect.getLimitString turns the whole sql to lowercase
> {code:title=SQLServer2005Dialect.java|borderStyle=solid}
>   @Override
>   public String getLimitString(String querySqlString, boolean hasOffset) {
>       StringBuilder sb = new StringBuilder(querySqlString.trim().toLowerCase());
> ...
>       return sb.toString();
>   }
> {code}
> thus also the included tablenames are all converted to lowercase, 
> this leads to following schema mismatch exception, when using the original SQLServerDriver:
>  org.hibernate.exception.SQLGrammarException: Invalid object name 'mytable'
> This bug was introduced with HHH-2655 (ROW_NUMBER for Paging).
> Testcase:
> {code}
>  Query query = session.createQuery("from C"); // C is an arbitrary entity class mapped to a table with uppercase characters in the tablename
>  query.setMaxResults(10);
>  query.iterate().next(); // -> Exception
> {code}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list