is db-jade-na-zlot
a valid schema/database name?
Probably you need to thick it putting
``
around this name to teach Hibernate to treat as identifier and quoting it into generated SQL
Question
I use Hibernate
to get data from MySQL 5.5.28
database, this is query from Hibernate with org.hibernate.exception.SQLGrammarException
error:
Hibernate:
select user0_.uid as uid1_0_0_, user0_.motorcycle as motorcyc2_0_0_, user0_.password as password3_0_0_, user0_.username as username4_0_0_
from db-jade-na-zlot.users user0_
where user0_.uid=1;
i try to check this in phpMyAdmin and this query works fine:
select user0_.uid as uid1_0_0_, user0_.motorcycle as motorcyc2_0_0_, user0_.password as password3_0_0_, user0_.username as username4_0_0_
from users user0_
where user0_.uid=1;
i checked 5 times database name in hibernate.cfg.xml, but it's ok. What i'm doing wrong?
hibernate.cfg.xml
<?xml version="1.0" encoding="utf-8"?>
<session-factory>
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/db-jade-na-zlot</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">vertrigo</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<mapping class="pl.jadenazlot.model.User"></mapping>
</session-factory>
error:
ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-jade-na-zlot.users user0_ where user0_.uid=1' at line 1
Solution
is db-jade-na-zlot
a valid schema/database name?
Probably you need to thick it putting
``
around this name to teach Hibernate to treat as identifier and quoting it into generated SQL