On Thu, Aug 5, 2010 at 10:19 AM, jackalista <j...@twaxx.com> wrote: > > Hi, > > I haven't used the tutorials for a while and I'm having a strange problem > where I get a hibernate exception about my Person class not being mapped: > > Caused by: org.hibernate.hql.ast.QuerySyntaxException: Person is not mapped > [from Person p where p.lastName=?] > > > I found a post by Matt that looks similar but is from 2007 here: > > http://appfuse.547863.n4.nabble.com/Person-is-not-mapped-from-Person-where-lastName-td578225.html#a578225 > > In this post, Matt resolves this problem by using the FQCN for Person in > the > HQL in the finder like so: > > public List<Person> findByLastName(String lastName) { > return getHibernateTemplate().find("from > com.foo.dcs.project.model.Person p where p.lastName=?", lastName); > } > > Using the FQCN works for me too but seems kind of nasty, is this required > now, we have to use fully qualified class names in the HQL statements? Or > is there some minor tweak to the tutorial approach that allows you to > simply > use the more usual "from Person p where p.lastName =?" in your HQL queries? > The last time I used appfuse was last December, and I didn't have to do > this > (I don't *think*), I don't have that code with me right now but I don't > remember having to do this. Can anybody shed some light on this? > Thanks... > > > >From the tutorial at http://appfuse.org/display/APF/Persistence:
If you specify a name value for your @Entity annotation (for example @Entity(name="person")), this will be the alias for HQL queries. If you don't specify this value, the name will match the short name of your class ( Person). If you want to change the table name that's generated, use the @Table <http://java.sun.com/javaee/5/docs/api/javax/persistence/Table.html>annotation with a "name" value.