Hallo,
seit kurzem habe ich diese SQLGrammarException. Ich hab einfachnochmal in Eclipse das Projekt neu aufgemacht und meine Tabellen in der Datenbank umbenannt. Habe jeweils das s weggenommen. Also z.B. "User" anstatt "Users". Die Mappingdateien habe ich demenstprechend angepasst.
Bei Ausführung des folgenden Criteria-Kommandos erhalte ich die Exception:
Code:
(List<Group>) getSession().createCriteria(Group.class)
.addOrder( Order.asc("name") )
.list();
Sieht ganz simpel aus und hat auch schonmal funktioniert .... aber warum geht das jetzt nicht mehr?
Hibernate version: 3
Mapping documents:
<?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="de.tfhberlin.eclipsophone.server.beans" auto-import="true">
<class name="Group" table="Group" lazy="false">
<id name="id" column="id" type="long" unsaved-value="0">
<generator class="native" />
</id>
<version name="version" column="version" unsaved-value="negative"/>
<property name="name" column="name" type="string" />
<property name="description" column="description" type="string" />
<set name="participating_users" table="UserGroup">
<key column="group_id" />
<many-to-many column="user_id" class="User" />
</set>
</class>
</hibernate-mapping>
Full stack trace of any exception that occurs:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:408)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:350)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:264)
org.acegisecurity.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:107)
org.acegisecurity.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:72)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:110)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:217)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:229)
org.acegisecurity.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:274)
org.acegisecurity.util.FilterChainProxy.doFilter(FilterChainProxy.java:148)
org.acegisecurity.util.FilterToBeanProxy.doFilter(FilterToBeanProxy.java:98)
Name and version of the database you are using:
MySQL 5
The generated SQL (show_sql=true):
Hibernate: select this_.id as id0_0_, this_.version as version0_0_, this_.name as name0_0_, this_.description as descript4_0_0_ from Group this_ order by this_.name asc
Session Factory:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref local="dataSource" />
</property>
<property name="mappingResources">
<list>
<value>Group.hbm.xml</value>
<value>User.hbm.xml</value>
<value>UserGroup.hbm.xml</value>
<value>GroupAdmin.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.cache">true</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.connection.release_mode">on_close</prop>
</props>
</property>
</bean>