-->
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.  [ 2 posts ] 
Author Message
 Post subject: [SOLVED] Damn SQLGrammerException
PostPosted: Wed Jul 08, 2009 1:26 pm 
Newbie

Joined: Wed Jul 08, 2009 1:09 pm
Posts: 2
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.


Last edited by fpsdyl on Wed Jul 08, 2009 1:38 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Damn SQLGrammerException
PostPosted: Wed Jul 08, 2009 1:38 pm 
Newbie

Joined: Wed Jul 08, 2009 1:09 pm
Posts: 2
Sorry guys, I actually did nothing but wasted your time...
I used hbm2java to generate these entities from the database.
and didn't see that the catalog was specified in my @Table...

I just removed that and it's working now...

Sorry for making you read that post:-D


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