-->
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.  [ 14 posts ] 
Author Message
 Post subject: Hibernate Localization Error
PostPosted: Mon Feb 13, 2006 5:07 am 
Newbie

Joined: Thu Jan 26, 2006 6:19 am
Posts: 19
Guys I've got a problem with Hibernate.
For a table named Interest (POJO class name is also the same). All the sql statements created by hibernate is faulty.

The sql statement that should be created is something like this:
select id, .. .. from interests interest0 ...

Here "interest0" is the lowercase of Interest plus "0".

However, hibernate uses my regional settings during the lower case convertion. Unfortunately, in Turkish the lowercase of I is not i. its another character like "ı".

How can I make it work? How can I tell hibernate not to use my local setting and use English as default??

Thanks..


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 13, 2006 5:31 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
implement you own NamingStrategy or override the table name specifically via the table attribute ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 13, 2006 5:34 am 
Newbie

Joined: Thu Jan 26, 2006 6:19 am
Posts: 19
max wrote:
implement you own NamingStrategy or override the table name specifically via the table attribute ?


How can I verride the table name specifically via the table attribute ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 13, 2006 5:34 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
http://javaalmanac.com/egs/java.util/SetDefLocale.html


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 13, 2006 5:36 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
table="interest"

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 13, 2006 5:36 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Code:
/** Useful constant for country.
     */
    static public final Locale UK = new Locale("en","GB","");

    /** Useful constant for country.
     */
    static public final Locale US = new Locale("en","US","");

    /** Useful constant for country.
     */
    static public final Locale CANADA = new Locale("en","CA","");


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 13, 2006 5:37 am 
Newbie

Joined: Thu Jan 26, 2006 6:19 am
Posts: 19
baliukas wrote:
http://javaalmanac.com/egs/java.util/SetDefLocale.html


if I change local to "ENUS", wont I lose the i18n of my web application?
then none of the resources will be read from my turkish resource.properties file, right?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 13, 2006 5:41 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Yes, you must not depend on default locale. Use way sugested by Max.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 13, 2006 6:20 am 
Newbie

Joined: Thu Jan 26, 2006 6:19 am
Posts: 19
max wrote:
table="interest"

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping package="com.salatta.dal">
    <class name="Invitation" table="invitations">
        <id name="id" type="integer" column="INV_ID">
            <generator class="org.hibernate.id.IncrementGenerator" />
        </id>
        <property name="name" column="NAME" type="string" not-null="false" length="25" />
        <property name="surname" column="SURNAME" type="string" not-null="false" length="25" />
        <property name="email" column="EMAIL" type="string" not-null="false" length="50" />
        <property name="invitationCode" column="INV_CODE" type="string" not-null="false" length="25" />
        <property name="invitationStatus" column="INV_STATUS" type="integer" not-null="false" length="11" />
        <many-to-one name="member" column="MEMBER_ID" class="Member" not-null="false"></many-to-one>
    </class>
</hibernate-mapping>

This is my hbm.xml file..
" <class name='Invitation' " part is used during the lowercase uperation
class name in written in lowercase.
When I change my class name to "Nvitation" it works.
But this is not a good solution.

If I overwrite NamingStrategy and tell hibernate to use invitation for the lowercase.. how can I inform hibernate that it should use the my CustomNamingStrategy class?[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 13, 2006 6:28 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
hmm...this part is actually not controllable.

The "faulty" code is StringHelper.generateAliasRoot(String description) which just uses lowercase.

Report it as a bug in jira.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 13, 2006 6:59 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Try "<?xml version="1.0" encoding="utf-8"?>" "toLowercase" method transforms UNICODE string (it does not depend on locale settings), you need to read correct characters from XML first (it depends on locale settings).
Probably it is a bug in parser utf-8 is default.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 13, 2006 7:48 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Sorry, I was wrong. It is a flaw in UNICODE standard, it use same code for all 'I' http://www.unicode.net/reports/tr21/tr21-3.html and it depends on locale settings and SUN hacket it this way:
public String toLowerCase() {
return toLowerCase(Locale.getDefault());
}
So you will need custom strategy:
http://www.hibernate.org/hib_docs/v3/re ... ngstrategy.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 13, 2006 10:06 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
the namingstrategy does not influence the alias generation afaik. I thought it did until now ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 13, 2006 10:40 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Yes, it needs paramater. It looks like UNICODE decided to save space in mapping table :)


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

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.