-->
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: BUG: Wrong JPA to MySQL mapping. LENGTH function.
PostPosted: Tue Apr 13, 2010 9:34 am 
Newbie

Joined: Mon Apr 12, 2010 12:41 pm
Posts: 1
Hi all,

I've recently used JPA function LENGTH (under JBoss 5.1.0 GA) and faced wrong behavior.

The following JPQL statement

Code:
SELECT d.id FROM Depositor d WHERE LENGTH(d.firstName) > :firstNameMinLength


was converted into the following native SQL statement through MySQLDialect

Code:
select depositor0_.id as id24_ from depositor depositor0_ where length(depositor0_.first_name)>?


It is incorrect IMHO because according to the section 4.6.16.1 of the JPA spec
Quote:
The LENGTH function returns the length of the string in characters as an integer.

but according to the MySQL documentation (http://dev.mysql.com/doc/refman/5.1/en/ ... ion_length)
Quote:
LENGTH(str)
Returns the length of the string str, measured in bytes


In the case of multibyte character encodings (russian chars in UTF-8 in my case) this leads into troubles.
In the right case the LENGTH() JPA function should be mapped onto the CHAR_LENGTH() MySQL function.


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.