-->
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.  [ 1 post ] 
Author Message
 Post subject: org.hibernate.hql.ast.QuerySyntaxException
PostPosted: Sat Oct 18, 2008 10:35 am 
Beginner
Beginner

Joined: Sat Oct 18, 2008 10:25 am
Posts: 30
Hallo,

ich versuche gerade mit Hibernate und MySql zu arbeiten, aber schon die einfachste HQL-Abfrage funktioniert nicht. Ich erhalte die Fehlermeldung org.hibernate.hql.ast.QuerySyntaxException: City is not mapped [select c from City c], aber ich kann beim besten Willen keinen Fehler in den Mapping-Dateien finden.

Vielleicht seht ihr etwas

Hier ist meine Mapping-Datei:


Code:
<?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 default-lazy="false" auto-import="false">
   <class name="de.waldhausweg7.model.City" table="city">
      <id name="cityId" column="cityid" type="int">
         <generator class="increment" />
      </id>
      <property name="postalCode" column="postalcode" />
      <property name="cityName" column="cityname" />
   </class>   
</hibernate-mapping>


In dieser Methode befindet sich die HQL-Abfrage:

Code:
      try {
         session = HibernateUtil.openSession();
         transaction = session.beginTransaction();
         cityList = session.createQuery("select c from City c").list();
         transaction.commit();
         return cityList;
      }


Und hier die hibernate.cfg.xml

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
   <session-factory>
      <!-- MySQL -->

      <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
      <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
      <property name="hibernate.connection.url">jdbc:mysql://localhost/esg</property>
      <property name="hibernate.connection.username">root</property>
      <property name="hibernate.connection.password">asdf</property>

      <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>

      <property name="current_session_context_class">thread</property>
      <property name="hibernate.show_sql">false</property>
      <property name="hibernate.formate_sql">false</property>


      <!-- Mappings --> 
      <mapping resource="de/waldhausweg7/model/Person.hbm.xml" />
      <mapping resource="de/waldhausweg7/model/City.hbm.xml" />
      <mapping resource="de/waldhausweg7/model/Category.hbm.xml" />
   </session-factory>
</hibernate-configuration>


Sieht jemand von euch den Fehler?

Vielen Dank im Voraus.

Christopher


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.