-->
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.  [ 5 posts ] 
Author Message
 Post subject: FinderGenerator: unexpected token: in
PostPosted: Fri Feb 20, 2004 10:33 am 
Newbie

Joined: Fri Feb 20, 2004 10:19 am
Posts: 2
Location: Helsinki, Finland
When trying to invoke a findAll method generated by FinderRender I received the following error. I'm unsure as to whether it was a configuration error on my behalf or an issue with regard to FinderRender itself.

Any information, would be great,
James

Version: Hibernate-2.1
Database: Postgre 7.3.4

config.xml
<codegen>
<generate renderer="net.sf.hibernate.tool.hbm2java.BasicRenderer"/>
<generate suffix="Finder" renderer="net.sf.hibernate.tool.hbm2java.FinderRenderer"/>
</codegen>

Resulting code...

public static List findAll(Session session) throws SQLException, HibernateException {
List finds = session.find("from AccessGateways in class org.ludo.bpd.data.hibernate.AccessGateways");
return finds;
}

Invoked:

Collection lGateways = AccessGateways.findAll(aHibernateSession)

Stacktrace:
VoucherStatus in class org.ludo.bpd.data.hibernate.VoucherStatus]
at net.sf.hibernate.hql.FromParser.token(FromParser.java:89)
at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
at net.sf.hibernate.hql.PreprocessingParser.token(PreprocessingParser.java:123)
at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:29)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138)
at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:293)
at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1493)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1464)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1454)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1446)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2004 12:45 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
This is very deprecated quere syntax. Try using the 2.1 style HQL syntax as in the current documentation.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2004 12:46 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Also, don't use the name of the class as the alias name (that is the cause of the exception, probably).


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 23, 2004 4:34 am 
Newbie

Joined: Fri Feb 20, 2004 10:19 am
Posts: 2
Location: Helsinki, Finland
Hi Gavin,
Indeed, it only seems to be for findAll methods that the generator createsm are with the deprecated syntax. Finder methods defined as meta attribute use the correct syntax.

I'm using a HibernateExtensions-2.0.2, though I've no time at the moment, I'll have a look inside the source and see if theres anything untoward, I'll post my findings toward the end of the week.


As part of thw .hbm I defined a

<property
name="name"
type="java.lang.String"
column="name"
not-null="true"
length="255"
>
<meta attribute="finder">findByName</meta>
</property>

The resulting code...

public class AccessGatewaysFinder implements Serializable {

public static List findByName(Session session, java.lang.String name) throws SQLException, HibernateException {
List finds = session.find("from AccessGateways as accessgateways where accessgateways.name=?", name, Hibernate.STRING);
return finds;
}

public static List findAll(Session session) throws SQLException, HibernateException {
List finds = session.find("from AccessGateways in class com.wificom.sab.data.hibernate.AccessGateways");
return finds;
}

}


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 23, 2004 10:57 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Add an issue to JIRA and Max will look at it.


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