Hi All,
I'm used to using Hibernate on a PostgreSQL database, but I got this new project I'm supposed to work on that updates a database nightly (MySQL), I've kind-off overstepped my dead line a bit, and I need to get this working as quickly as possible.
I have code that looks like this :
Code:
List<PsCategory> existingCats =
entityManager.createQuery( "from PsCategory" ).getResultList();
and My persistence.xml looks likes this :
Code:
<persistence-unit name="MySQLJobHandler">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/MySQLJobHandlerDatasource</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>
<property name="hibernate.hbm2ddl.auto" value="validate"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="false"/>
<property name="jboss.entity.manager.factory.jndi.name" value="java:/MySQLJobHandlerEntityManagerFactory"/>
<property name="hibernate.default_schema" value="proshop"/>
</properties>
</persistence-unit>
Now when that top getResultList() executes hibernate prints this out :
Code:
19:05:00,218 INFO [STDOUT] Hibernate: select pscategory0_.id_category as id1_88_, pscategory0_.active as active88_, pscategory0_.date_add as date3_88_, pscategory0_.date_upd as date4_88_, pscategory0_.id_parent as id5_88_, pscategory0_.level_depth as level6_88_ from proshop.proshop.ps_category pscategory0_
19:05:00,264 WARN [JDBCExceptionReporter] SQL Error: 1064, SQLState: 42000
19:05:00,264 ERROR [JDBCExceptionReporter] 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 '.ps_category pscategory0_' at line 1
19:05:00,266 ERROR [ImportAction] javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
I run MySQL 5.0.75, and I tried running that query in the mysql-console, but got the same "You have an error in your SQL syntax...",
and I realized it's because of the proshop.proshop.ps_category, because when I change it to : proshop.ps_category it works with no
problems.
So I guess my actual question would be why does hibernate put proshop.proshop in the from instead of just proshop. and how I can get
it to function normally.