[Hibernate-JIRA] Commented: (HB-849) Locale issue with the generated class alias name
by Orhan Yilmaz (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HB-849?page=com... ]
Orhan Yilmaz commented on HB-849:
---------------------------------
this is a permanently the solution but hibernate sql generator must use en_US locale.
-----------------------
package com.eksera.service;
import org.hibernate.*;
import org.hibernate.cfg.*;
import java.util.Locale;
import java.util.Properties;
import java.util.List;
import org.apache.log4j.Logger;
public class HibernateSession {
private static Logger logger = Logger.getLogger(HibernateSession.class.getName());
public static Properties props = null;
private static SessionFactory sessionFactory = null;
private static final ThreadLocal threadSession = new ThreadLocal();
private static final ThreadLocal threadTransaction = new ThreadLocal();
static {
//#### set locale here
Locale.setDefault(Locale.ENGLISH);
Configuration c = new Configuration().configure();
props = c.getProperties();
sessionFactory = c.buildSessionFactory();
}
public static Properties getProperties() {
return props;
}
public static Session openSession() {
Session s = (Session) threadSession.get();
if (s == null) {
s = sessionFactory.openSession();
threadSession.set(s);
}
return s;
}
public static void closeSession() {
Session s = (Session) threadSession.get();
threadSession.set(null);
if (s != null && s.isOpen())
s.close();
}
public static void beginTransaction() {
Transaction tx = (Transaction) threadTransaction.get();
if (tx == null) {
tx = openSession().beginTransaction();
threadTransaction.set(tx);
}
}
public static void commitTransaction() {
Transaction tx = (Transaction) threadTransaction.get();
if ( tx != null && !tx.wasCommitted()
&& !tx.wasRolledBack() )
tx.commit();
threadTransaction.set(null);
}
public static void rollbackTransaction() {
Transaction tx = (Transaction) threadTransaction.get();
try {
threadTransaction.set(null);
if ( tx != null && !tx.wasCommitted()
&& !tx.wasRolledBack() ) {
tx.rollback();
}
} finally {
closeSession();
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
}
> Locale issue with the generated class alias name
> ------------------------------------------------
>
> Key: HB-849
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HB-849
> Project: Hibernate2
> Type: Bug
> Components: core
> Environment: Hibernate 2.2
> Reporter: Reha CENANI
> Assignee: Emmanuel Bernard
>
> Original Estimate: 1 minute
> Remaining: 1 minute
>
> generateAlias method of the net.sf.hibernate.loader.Loader uses toLowerCase() when generating class aliases. Since the toLowerCase() makes conversion by using the default system locale, some non-English locales (e.g. Turkish) cause improper alias generation.
> For example, when the default system locale is set to Turkish (tr_TR), letter 'I' is converted to 'dotless i', instead of 'i'. Because of this, generated aliases and the sql statements which depend on these aliases contain wrong characters.
> In order to prevent this situation, replacing toLowerCase() with toLowerCase(Locale.US) explicitly determines which locale will be used during the conversion.
--
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
18 years, 2 months
[Hibernate-JIRA] Commented: (HHH-1629) SchemaUpdate doesn't work with Postgres
by Nicklas Nordborg (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1629?page=c... ]
Nicklas Nordborg commented on HHH-1629:
---------------------------------------
Any chance that this issue will be solved in the near future? We have users running on Postgres that are unable to upgrade to the latest version of our software.
> SchemaUpdate doesn't work with Postgres
> ---------------------------------------
>
> Key: HHH-1629
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1629
> Project: Hibernate3
> Type: Bug
> Versions: 3.1.2
> Environment: Hibernate 3.1.2
> Postgres 8.0.4
> Linux
> Reporter: Nicklas Nordborg
> Priority: Trivial
> Attachments: AffyFeatureData.hbm.xml, patch-HHH-1629.txt
>
>
> The SchemaUpdate only generates SQL with CREATE TABLE statements and can't update existing tables.
> With debugging turned on the SchemaUpdate reports:
> 11:25:22,599 INFO SchemaUpdate:114 - Running hbm2ddl schema update
> 11:25:22,599 INFO SchemaUpdate:126 - fetching database metadata
> .11:25:22,771 INFO SchemaUpdate:142 - updating schema
> 11:25:22,803 INFO DatabaseMetadata:91 - table not found: AffyFeatures
> 11:25:22,830 INFO DatabaseMetadata:91 - table not found: AnnotationSets
> 11:25:22,855 INFO DatabaseMetadata:91 - table not found: AnnotationTypeItems
> .... and so on for another 100+ tables
> All tables except two exists in the database. The two new tables are created successfully by SchemaUpdate.
> I attach one of my mapping files (generated by XDoclet).
> I had a quick look at the SchemaUpdate code (which calls DatabaseMetadata) and I think the problem is that it converts the table names to upper or lower case, even though I have quoted them in the mapping files. If the DatabaseMetadata.getTableMetadata could take a Table object as a parameter instead of the name, schema and catalog, it could check the Table.isQuoted() method before converting any names to upper or lower case. It seems like this method is only used by the Configuration class so it shouldn't be too hard to fix.
> I could do the fix myself, but I will only be able to validate it against Postgres and MySQL using quoted table names. So, others would probably have to validate it agains other databases and using unquoted table names.
--
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
18 years, 2 months