-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: FirebirdDialect getLimitString error and fix
PostPosted: Thu Dec 21, 2006 11:38 am 
Newbie

Joined: Fri Sep 22, 2006 1:22 pm
Posts: 3
Hibernate version: 3.2 GA

Firebird 2.0

While I am certain this is bug, the process does state to post this to the forum for feedback so I am following the process first.

I have found that if I have sql comments turned on the FirebirdDialect generates an incorrect limitString.

The current FirebirdDialect getLimitString looks like the following:
Code:
   public String getLimitString(String sql, boolean hasOffset) {
      return new StringBuffer( sql.length()+20 )
         .append(sql)
         .insert(6, hasOffset ? " first ? skip ?" : " first ?")
         .toString();
   }

Which generates sql like:
Code:
Hibernate:
    /* cri first ? skip ?teria query */ select
        this_.id as id1_0_,
        this_.h_version as h2_1_0_,
        this_.name as name1_0_
    from
        domain_b this_


If I change the method like:
Code:
   public String getLimitString(String sql, boolean hasOffset) {
      
      StringBuffer limitBuf = new StringBuffer( sql.length()+20 );
      
      limitBuf.append(sql);
      int index = sql.indexOf("select");
      if( index < 0 ) index = sql.indexOf("SELECT");
      
      if( hasOffset ) {
         limitBuf.insert(index+6, " first ? skip ?");
      } else {
         limitBuf.insert(index+6, " first ? ");
      }
      return limitBuf.toString();
   }


The output look like:
Code:
Hibernate:
    /* criteria query */ select
        first ? skip ? this_.id as id1_0_,
        this_.h_version as h2_1_0_,
        this_.name as name1_0_
    from
        domain_b this_


I think its a bug - comments?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.