-->
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: unexpected token: in [from MyClass in class MyClass
PostPosted: Mon Jun 14, 2004 1:19 pm 
Newbie

Joined: Mon Jun 14, 2004 12:59 pm
Posts: 1
Using Hibernate 2.1

hbm2java tool automatically generates the following code in a finder:

public static List findAll() throws SQLException, HibernateException {
Session session = com.X.Util.currentSession();
List finds = session.find("from MyClass in class com.X.hibernate.MyClass");
return finds;

This code produces the follwing error:

net.sf.hibernate.QueryException: unexpected token: in [from MyClass in class X.hibernate.MyClass]

The codegen.xml file is as follows:

<codegen>
<meta attribute="class-description">
@author me
</meta>
<meta attribute="session-method">
com.X.Util.currentSession();
</meta>
<meta attribute="implement-equals">true</meta>
<meta attribute="extends">com.X.MyBaseClass</meta>
<generate renderer="net.sf.hibernate.tool.hbm2java.BasicRenderer"/>
<generate package="com.X.hibernate.finders" prefix="Find" renderer="net.sf.hibernate.tool.hbm2java.FinderRenderer"/>
</codegen>

The hbm file is :

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping package="com.X.hibernate">
<class name="MyClass" table="MyClass">
<meta attribute="class-code">
private java.util.List roomNames;
public java.util.List getRoomNames(){
return roomNames;
}
public java.util.List setRoomNames(){
try{
net.sf.hibernate.Session session = com.X.Util.currentSession();
roomNames =session.find("Select room.name from MyClass as room");
}catch(Exception e){
System.out.println("MyClass.getRoomNames "+e);
}catch(java.lang.NoClassDefFoundError e){
System.out.println("e");
}
if (roomNames==null){
roomNames= new java.util.ArrayList();
}
return roomNames;
}
</meta>
<id name="id" type="long" column="uid" unsaved-value="0">
<generator class="identity"/>
</id>
<property name="clubID" type ="string" not-null="true" length="10">
<meta attribute="use-in-tostring">true</meta>
<meta attribute="use-in-equals">true</meta>
<meta attribute="finder-method">findByClub</meta>
</property>
<property name="name" not-null="true" type="java.lang.String" length="50">
<meta attribute="use-in-tostring">true</meta>
<meta attribute="use-in-equals">true</meta>
</property>
<component name="phoneNumber" class="com.X.hibernate.PhoneNumber">
<property name="areaCode" type="string" length="3" not-null="false"/>
<property name="exchange" type="string" length="3" not-null="false"/>
<property name="number" type="string" length="4" not-null="false"/>
</component>
<property name="maitred" type="java.lang.String" length="50" not-null="false"/>
<set name="menus">
<key column="uid"/>
<many-to-many class="com.X.hibernate.Menu"/>
</set>
<set name="tables">
<key column="uid"/>
<one-to-many class="com.X.hibernate.Table"/>
</set>
<set name="times">
<key column="uid"/>
<one-to-many class="com.X.hibernate.Time"/>
</set>
</class>

Class names were changed to protect privacy so it is not inconceivable I screwed somthing up in the cut and paste. If something looks odd then instead of spending time on it please let me know and I will clarify.

Is this in an error in the generator or some missing configuration element? Any ideas


Top
 Profile  
 
 Post subject: Re: unexpected token: in [from MyClass in class MyClass
PostPosted: Tue Jul 20, 2004 1:56 pm 
Newbie

Joined: Tue Jul 20, 2004 1:25 pm
Posts: 12
I'm getting the same problem. Everytime I regenerate my finder classes I have to modify the HQL so that its valid.

Anybody found a solution for this?

version info:
hibernate 2.1.2
hibernate-extension 2.1.2


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.