-->
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.  [ 9 posts ] 
Author Message
 Post subject: hbm2java: Finder method generation
PostPosted: Fri Oct 17, 2003 3:35 pm 
Newbie

Joined: Fri Oct 17, 2003 3:21 pm
Posts: 4
Hi,

hbm2java is not generating finder method for me. It does generate finder class, but method I requested is not there.

Here is my hibernate mapping section:
########################
<class name="com.softpenter.dts.entitiesImpl.EmployerImpl" table="employers">

<id name="id" type="long">
<generator class="native"/>
</id>

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

</class>
########################



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



The ant taks is:
########################
<target name="generatecode">
<java
classpathref="hibernate.tools.class.path"
classname="net.sf.hibernate.tool.hbm2java.CodeGenerator"
fork="true">

<arg value="--config=hbm2java.config.xml"/>
<arg value="--output=${src.dir}"/>
<arg value="${src.dir}/hbm/*.hbm.xml"/>

</java>
</target>
########################



The generated code is:
########################
package com.softpenter.dts.entitiesImpl;

import java.io.Serializable;
import java.util.List;
import java.sql.SQLException;

import net.sf.hibernate.*;
import net.sf.hibernate.type.Type;

/** Automatically generated Finder class for EmployerImplFinder.
* @author Hibernate FinderGenerator **/
public class EmployerImplFinder implements Serializable {

public static List findAll(Session session) throws SQLException, HibernateException {
List finds = session.find("from EmployerImpl in class com.softpenter.dts.entitiesImpl.EmployerImpl");
return finds;
}

}
########################


It only generates the find all method, not findByName method.

What am I missing?

I am using
hibernate - version 2.0.3, 27 August 2003
extensions - version 2.1 12. June 2003

Thanks,
Prashant Rane


Top
 Profile  
 
 Post subject: Re: hbm2java: Finder method generation
PostPosted: Mon Oct 20, 2003 1:18 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Try to use "finder" instead of "finder-method".

If that works you are using a old version of hibernate extensions.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Using just finder works.
PostPosted: Mon Oct 20, 2003 1:38 pm 
Newbie

Joined: Fri Oct 17, 2003 3:21 pm
Posts: 4
Thanks for help Max.

Using just finder instead of finder-method works.

I will update the extensions version as you suggested.

Thanks,
Prashant Rane


Top
 Profile  
 
 Post subject: Where to get latest extensions from?
PostPosted: Mon Oct 20, 2003 2:24 pm 
Newbie

Joined: Fri Oct 17, 2003 3:21 pm
Posts: 4
Hi,

I am using the latest build from sourceforge for hibernate extensions.
hibernate-ext 2.0 June 12, 2003

hibernate-extensions-2.0.zip
464 KB.

I am gettnig the finder / finder-method problem, while using this build.

Is this the latest build?
If not, how to get the latest?

Thanks,
Prashant Rane


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 21, 2003 5:34 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
hmm....CVS got the latest.

We should get a new release out of hibernate-extensions ASAP - right, Christian ? ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 21, 2003 5:59 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Eh, yes :)

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject: hbm2java
PostPosted: Sat Dec 20, 2003 6:24 pm 
Newbie

Joined: Sat Dec 20, 2003 5:55 pm
Posts: 1
I think the current release of hbm2java in Hibernate Extensions version 2.0.2 - 22.10.2003 is broken. I'm getting findAll methods (instead of the ones I specified in my hbm.xml file) and what is genereated has i0nvalid HQL. I've seen the previous posts about this issue, from Oct. 20th, and I'm having the same errors. I looked at the FinderRenderer source included with the 2.0.2 release and it still has the "finder" attribute and not "finder-method". I assume that the Oct 22nd release did not include the correct versions?

I'm sure this is fixed in CVS, but I cannot even successfully build the tools :-( Anyway, if someone has the latest hibernate-tools.jar on the web, please point me to it. Perhaps someone could update the tools release?

Any help is greatly appreciated.

Thanks

Chris


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 31, 2003 3:38 pm 
Newbie

Joined: Wed Dec 31, 2003 3:34 pm
Posts: 5
Location: Toronto, Canada
the version of FinderRender that I just checked out of CVS still has "finder", not "finder-method".

Even after changing this and rebuilding, I'm still not getting the methods I expect.

I'm using Hibernate 2.1 - could there be some subtle incompatibility here?


Top
 Profile  
 
 Post subject: Still not updated?
PostPosted: Thu Mar 04, 2004 10:19 pm 
Newbie

Joined: Fri Feb 27, 2004 6:17 pm
Posts: 11
I pulled down the latest release versions (2.1.2 of Hibernate, and 2.0.2 of Hibernate Extensions) and I still only get the finder generated stuff, not the finder-method.

And, FWIW, here's the generated code...

Code:
    public static List findByAlias(Session session, java.lang.String alias) throws SQLException, HibernateException {
        List finds = session.find("from ExamAuthor as examauthor where examauthor.alias=?", alias, Hibernate.STRING);
        return finds;
    }

    public static List findAll(Session session) throws SQLException, HibernateException {
        List finds = session.find("from ExamAuthor in class com.cascadetg.ch02.ExamAuthor");
        return finds;
    }


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