-->
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: named query not found exception
PostPosted: Tue Aug 17, 2004 4:52 pm 
Newbie

Joined: Fri Aug 13, 2004 12:06 pm
Posts: 15
Hibernate version: 2.1.4

Mapping documents: excerpt included

Code between sessionFactory.openSession() and session.close(): n/a

Full stack trace of any exception that occurs: no

Name and version of the database you are using: Pointbase

Debug level Hibernate log excerpt:


I am trying to use a named query that is in the same mapping document as the persistent class it relates to, but Hibernate isw throwing an exception:

In my RecordingBean.hbm.xml file:

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

<hibernate-mapping schema="weblogic" package="relationships">

<class name="RecordingBean" table="RECORDING" lazy="true">

<meta attribute="class-description">
This JavaBean class is for interacting with the RECORDING
table.
@author Me
</meta>

<composite-id>
<key-property name="bandname" type="string" column="BANDNAME">
<meta attribute="field-description">Returns band's name.</meta>
<meta attribute="use-in-tostring">true</meta>
</key-property>
<key-property name="title" type="string" column="TITLE">
<meta attribute="field-description">Returns recording name.</meta>
<meta attribute="use-in-tostring">true</meta>
</key-property>
</composite-id>

<property name="rating" type="string"
column="RATING" length="150" not-null="false">
<meta attribute="field-description">Returns popularity rating for the recording.</meta>
<meta attribute="use-in-tostring">true</meta>
</property>
<property name="bandejb_name" type="string"
column="BANDEJB_NAME" length="150" not-null="false">
<meta attribute="field-description">Returns WebLogic-specific data.</meta>
<meta attribute="use-in-tostring">true</meta>
</property>
<property name="wls_temp" type="integer"
column="WLS_TEMP" length="10" not-null="false">
<meta attribute="field-description">Returns WebLogic-specific data.</meta>
<meta attribute="use-in-tostring">true</meta>
</property>

</class>

<!-- named queries -->
<query name="relationships.recordingsByBand">
<![CDATA[
from relationships.RecordingBean as rb
where upper(rb.bandname) = :name
order by rb.bandname, rb.title
]]>
</query>

</hibernate-mapping>



In my code to use it:

Query q = HibernateUtil.currentSession().getNamedQuery(
"relationships.recordingsByBand");

Exception message:

"Named query not known: relationships.recordingsByBand"


Can someone please help with this? Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 17, 2004 5:17 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
no stack trace ? hard to help then...

My guess is you have more than one hbm.xml file named the same in your classpath...or maybe just editing one and using another

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 17, 2004 6:03 pm 
Newbie

Joined: Fri Aug 13, 2004 12:06 pm
Posts: 15
I doubt it is a classpath problem or a duplicate file problem, because I only have two mapping files and two persistent classes. Both mapping files are in the same directory as the JavaBeans Java files and one of them is working (the one without the named query in it).


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 17, 2004 6:07 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
what about the stacktrace max asked for?
you don't have it?

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 17, 2004 6:20 pm 
Newbie

Joined: Fri Aug 13, 2004 12:06 pm
Posts: 15
I don't have it in a form that can copied easily here. It says nothing but how the method got called that uses the getNamedQuery() method and then "Named query not found."


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 18, 2004 1:27 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
the "nothing but how the method got called" is actually the most important part of the puzzle!

If you can't show failing code and/or stacktrace then I can't help much as the getNamedQuery functionallity works as expected here.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 18, 2004 9:51 am 
Newbie

Joined: Fri Aug 13, 2004 12:06 pm
Posts: 15
Here's a screen capture of the error messages... I hope you can find some hidden message in there that I don't see.
Image


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 18, 2004 5:03 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
The exception references to "recordingsByBand" but your examples refer to "relationships.recordingsByBand" ....that's two different names....maybe the problem is there?!

Btw. You do know that one can copy arbitrary text from a console prompt....

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 18, 2004 5:33 pm 
Newbie

Joined: Fri Aug 13, 2004 12:06 pm
Posts: 15
Max, I finally found the problem with this one. You were right in your first reply. I thought I checked for duplicate files, but oops! The problem is my Ant build script expects them in one place and my BEA Weblogic expects them in another. I haven't figured it out yet to make them one in the same.
Thanks a million! (It still isn't working though. Something else is wrong now!)


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.