- This topic has 4 replies, 3 voices, and was last updated 19 years, 2 months ago by
Haris Peco.
-
AuthorPosts
-
Christian CasamirraMemberHow can I configure Hibernate to use MySQL backticks?
I follow the MyEclipse_Hibernate_Quickstart and create my HibernateDemo project but …
SQLGrammarException: ….This is the query as in the ‘mysql_query.log’:
insert into test__mymsg (num, desc) values (‘one’, ‘desc number 1.’)And this is the query that works in the DataBase Explorer:
insert into test.mymsg (`num`, `desc`) values (‘one’, ‘desc number 1.’)… the only diffrence is in the columns backticks, but I can’t find any place to configure it.
I’ve already tried changing the MySQL dialects … but nothing.I use Eclipse 3.1.1, MyEclipse 4.1, MySQL 5.0.18.
In other forum I’ve found that:
http://opensource2.atlassian.com/projects/hibernate/browse/HB-1539but it doesn’t help me much.
Riyad KallaMemberThis is a Hibernate question, MyEclipse cannot instrument Hibernate to change this. It does seem like a real enough issue that others should have run into it on the Hibernate forums, have you checked there or seen if there is a mysql-specific property for it?
Haris PecoMemberand this is error
test__mymsg
correct is test.mymsg
best
Christian CasamirraMemberSolved.
The problem was in the mapping file:
_ added the backticks to the column and table names
_ removed the catalog name.This DON’T works.
<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <!-- Mapping file autogenerated by MyEclipse - Hibernate Tools --> <hibernate-mapping> <class name="casc.hib.test.Mymsg" table="mymsg" catalog="test"> <composite-id name="id" class="casc.hib.test.MymsgId"> <key-property name="num" type="java.lang.String"> <column name="num" length="45" /> </key-property> <key-property name="desc" type="java.lang.String"> <column name="desc" length="45" /> </key-property> </composite-id> </class> </hibernate-mapping>
And this works.
<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <!-- Mapping file autogenerated by MyEclipse - Hibernate Tools --> <hibernate-mapping> <class name="casc.hib.test.Mymsg" table="`mymsg`"> <composite-id name="id" class="casc.hib.test.MymsgId"> <key-property name="num" type="java.lang.String"> <column name="`num`" length="45" /> </key-property> <key-property name="desc" type="java.lang.String"> <column name="`desc`" length="45" /> </key-property> </composite-id> </class> </hibernate-mapping>
Haris PecoMembercasc,
This mapping
<?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <!-- Mapping file autogenerated by MyEclipse - Hibernate Tools --> <hibernate-mapping> <class name="casc.hib.test.Mymsg" table="mymsg" catalog="test"> <composite-id name="id" class="casc.hib.test.MymsgId"> <key-property name="num" type="java.lang.String"> <column name="num" length="45" /> </key-property> <key-property name="desc" type="java.lang.String"> <column name="desc" length="45" /> </key-property> </composite-id> </class> </hibernate-mapping>
is correct mapping, but doesn’t work , because exists hibernate bug (incorrect make table name).
We fixed bug in 4.1.1best
-
AuthorPosts