-->
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.  [ 8 posts ] 
Author Message
 Post subject: Hibernate SQL Table mapping problem
PostPosted: Thu Aug 28, 2008 4:53 am 
Newbie

Joined: Tue Aug 26, 2008 10:55 am
Posts: 8
Hello,

I have a question about the mapping of hibernate.
There are attributes for defining the table name and the column name.

In my case hibernate seems to completely ignore them.

I have the tables created in uppercase in my database.
Hibernate says, that the tables were not created.
If I tell hibernate to create the tables, it creates the tables in lowercase names. All works fine then.

How can I tell Hibernate to use the uppercase tables please?

Thanks in advance

Guenther

Hibernate version:
3.1.3 deployed in Tomcat 6

Mapping documents:
One Example mapping, the others are similar:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.onetreetech.kitchen.hibernate.entity"
   default-access="com.onetreetech.kitchen.hibernate.ImprovedPropertyAccessor">
   <joined-subclass name="Recipe" table="RECIPE" extends="Action">
      <key column="ACTION_ID" />
      <property name="image_location" column="IMAGE_LOCATION"
         type="string" />
      <set name="actions" table="ASSOCIATION">
         <key column="RECIPE_ID" not-null="true" />
         <many-to-many column="ACTION_ID" unique="true"
            class="Action" />
      </set>
   </joined-subclass>
</hibernate-mapping>


Spezial Changes:
I implemented a own PropertyAccessorClass.
Cache Provider is NoCacheProvider because of ehcache problems.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 28, 2008 5:35 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Some database are picky about upper/lower case and happily convert names unless you force them to be a specific case. This usually means that you need to quote table/column names whenever you use them. In Hibernate this is done by enclosing your table/column names in back-ticks. Eg. table="`RECIPE`", column="`ACTION_ID`" and so on.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 28, 2008 5:56 am 
Newbie

Joined: Tue Aug 26, 2008 10:55 am
Posts: 8
Hello,

thanks for the reply.

I'm sorry, It didn't help.
It seems to ignore the back-tips (`). He converts the table="`RECIPE`"
into a `recipe` table identifier.

As additional information I could say that I'm working with MySQL on a Gentoo Linux. Therefore I have the MySQL dialect enabled.
I'll try to disable it and see whether the error is still there.

Thanks again

Guenther


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 28, 2008 6:03 am 
Newbie

Joined: Tue Aug 26, 2008 10:55 am
Posts: 8
Hello,

there was no change when disabling the mysql dialect option.

Guenther


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 28, 2008 6:42 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
This seems strange indeed. I have never seen Hibernate change the case of table/column names. This usually happens in the database. For MySQL I have only seen this on Window were the file system is case-insensitive.

What do you mean with disabling the mysql dialect option? If I don't specify a dialect I get a "org.hibernate.HibernateException: Dialect class not found:" exception.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 28, 2008 6:57 am 
Newbie

Joined: Tue Aug 26, 2008 10:55 am
Posts: 8
I didn't configure the "hibernate.dialect".
That doesn't throw any error.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 28, 2008 8:27 am 
Newbie

Joined: Tue Aug 26, 2008 10:55 am
Posts: 8
I found out, that you can adapt your mysql database by setting lower_case_table_names to 1.

Seems to me as a bad hack for solving this problem!

http://dev.mysql.com/doc/refman/5.0/en/ ... ivity.html

Why does hibernate ignore the names I gave to it please?

Thanks

Guenther


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 28, 2008 8:36 am 
Newbie

Joined: Tue Aug 26, 2008 10:55 am
Posts: 8
Hello,

I solved the problem!

I had set the naming strategy to ImprovedNamingStrategy class.
Seems that this overrides all the settings in the configuration.

Thanks for your help nordborg.

Bye

Guenther


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.