-->
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: named query alias is not mapped
PostPosted: Sat Feb 25, 2006 10:14 am 
Newbie

Joined: Sat Feb 25, 2006 9:56 am
Posts: 6
I have a named query using hibernate 3 that is giving me an error saying that my alias is not mapped.

I am using XDoclet to generate the hibernate xml. Here is the xdoclet tags.

@hibernate.class table="csr_user" discriminator-value="USER"
@hibernate.query name="findByUsername" query="from USER m where m.username = :username"

this is the relevant snippets that xdoclet generates

from User.hbm.xml

<class
name="com.bglgroup.indulge.dataobjects.User"
table="csr_user"
discriminator-value="USER"
>

<query name="findByUsername"><![CDATA[
from USER m where m.username = :username
]]></query>


from hibernate.cfg.xml
<mapping resource="com/bglgroup/indulge/dataobjects/User.hbm.xml"/>

This is the stacktrace.

ERROR http-8080-Processor24 org.hibernate.impl.SessionFactoryImpl - Error in named query: findByUsername
org.hibernate.hql.ast.QuerySyntaxException: USER is not mapped. [
from USER m where m.username = :username
]
at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister

If I replace USER with the fully qualified name com.bglgroup.indulge.dataobjects.User it works just fine.

All my other classes that I've wrote the exact same way seem to work just fine.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 27, 2006 12:21 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Most likely, that's a package issue. Is User in a different package that the class you're referencing it from?

I don't know how to import mappings from different packages in xdoclet annotations, though. Sorry. If it helps, the .hbm.xml syntax you want is
Code:
<import class="com.bglgroup.indulge.dataobjects.User"/>


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.