-->
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: Query Syantax for findAll Method
PostPosted: Tue Mar 22, 2005 10:48 pm 
Newbie

Joined: Tue Mar 22, 2005 10:31 pm
Posts: 8
Hibernate version: 2.1.8

To Whom It May Concern,

I recently moved from using Jenny from Java Ranch to using Hibernate to handle my object/relational mapping and I must say Hibernate is extremely impressive. I have been using the Hibernate book by Will Iverson to learn from.

I have been writting my hbm.xml files by handing and using an ant task to build my java classes. I am having trouble with the findAll method that is getting generated in my Finder classes. Below is one of my hbm.xml files:

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

<hibernate-mapping>

<class name="com.echostorm.resumes.evaluator.hibernate.Skill" table="skill">

<id name="id" type="string" column="ID">
<meta attribute="finder-method">findByID</meta>
<generator class="uuid.hex" />
</id>

<version column="revision" name="revision" />

<property name="name" type="string"
column="name" length="100" >
<meta attribute="finder-method">findByName</meta>
</property>

<property name="description" type="string"
column="description" length="500" />

<property name="department" type="string"
column="department" length="100" >
<meta attribute="finder-method">findByDepartment</meta>
</property>

</class>
</hibernate-mapping>


It's straight forward and simple. The Finder classes has this method:

public static List findAll(Session session) throws SQLException, HibernateException {
List finds = session.find("from Skill in class com.echostorm.resumes.evaluator.hibernate.Skill");
return finds;

Now when I used this method I kept getting an Exception which was:
net.sf.hibernate.QueryException: unexpected token: in [from Skill in class com.echostorm.resumes.evaluator.hibernate.Skill]


I caught up with the CTO at work and he took a look at it and changed the Query in the findAll method to this:

public static List findAll(Session session) throws SQLException, HibernateException {
List finds = session.find("from com.echostorm.resumes.evaluator.hibernate.Skill as skill");
return finds;

Now it works. What I would really like is for hibernate to build my findAll methods with this structure and not the other. I guess what I would like to know is how is the findAll method defined? Can I make a change in my hbm.xml file to get it to generate the findAll like this?

I am not exactly sure where I can go for this? I know you time is important but any guidance would be much appreciated.


Sincerely,

Vince Cordaro
echostorm.net


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 23, 2005 6:05 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
this is the not very maintained FinderRenderer in hbm2java for hibernate 2.

I hibernate 3 hbm2java i have removed it since it was not maintained.
you are very welcome to go look at the new hibernate 3 tools and contribute a velocity template that generates the finders.

/max

_________________
Max
Don't forget to rate


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.