-->
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.  [ 5 posts ] 
Author Message
 Post subject: Named Queries vs hibernate.cfg.xml
PostPosted: Sun Aug 28, 2005 11:29 am 
Regular
Regular

Joined: Tue May 24, 2005 9:06 am
Posts: 64
Hibernate version: 3.1beta1
Annotations version: 3.1beta4
Name and version of the database you are using: MySQL 5.0.11

I defined Named Queries which are found and loaded when I'm using AnnotationConfiguration and the method addAnnotatedClass. However,
when declaring the persistent classes in hibernate.cfg.xml I get a runtime error when a Named Query is invoked.

Stack trace of the exception that occurs:

javax.servlet.ServletException: Named query not known: kunde.byNachname
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 29, 2005 4:22 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Hum, this is very weird. How are you declaring the class in the config file?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 30, 2005 1:07 am 
Regular
Regular

Joined: Tue May 24, 2005 9:06 am
Posts: 64
This is my hibernate.cfg.xml

<?xml version="1.0" ?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
<mapping class="de.hska.kundenverwaltung.db.KundeData"/>
<mapping class="de.hska.bestellwesen.db.BestellungData"/>
</session-factory>
</hibernate-configuration>

I also tried (same exception):
<hibernate-configuration>
<session-factory>
<mapping package="de.hska.kundenverwaltung.db">
<mapping package="de.hska.bestellwesen.db">

<mapping class="de.hska.kundenverwaltung.db.KundeData"/>
<mapping class="de.hska.bestellwesen.db.BestellungData"/>
</session-factory>
</hibernate-configuration>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 30, 2005 1:29 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
If you can provide a simple junit runnable testcase that reproduce the issue, then, post it to JIRA.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 18, 2005 4:02 am 
Regular
Regular

Joined: Tue May 24, 2005 9:06 am
Posts: 64
The problem is the annotations documentation.

In chapter 1.2 there is:
"sessionFactory = new AnnotationConfiguration().
.add...
.buildSessionFactory();"

When you are using hibernate.cfg.xml then you have to invoke the method configure() for the created AnnotationConfiguration object. Same procedure as using Hibernate w/o annotations.


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