-->
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.  [ 4 posts ] 
Author Message
 Post subject: List problem
PostPosted: Tue Aug 01, 2006 6:21 am 
Newbie

Joined: Mon Oct 17, 2005 4:10 am
Posts: 6
Hi

I am very new to Hibernate

In my application, i can enter records into database but i am unable to list them in a jsp. here is the code..

code in my jsp:

Code:
<%
Session hibsession = null;

try{
         System.out.println("Listing Records..");
         // This step will read hibernate.cfg.xml and prepare hibernate for use
         SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
          hibsession =sessionFactory.openSession();
         
          org.hibernate.Transaction tx = hibsession.beginTransaction();
         
            List empList = hibsession.createQuery("from empdata order by empid").list();
            Iterator empIter = empList.iterator();
            
            while(empIter.hasNext()){
            
            Empdata empdata = (Empdata)empIter.next();
%>


This is the error in console:

Code:
empdata is not mapped. [from empdata order by empid]


plz let me know where i am making the mistake...


Rgds,
Jim.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 01, 2006 7:06 am 
Regular
Regular

Joined: Wed May 05, 2004 3:41 pm
Posts: 118
Location: New Jersey,USA
I think the query should be

Code:
from Empdata as empdata order by empid


Unless you use "as" to alias Hibernate would think the value is a mapped peristent class.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 01, 2006 7:06 am 
Expert
Expert

Joined: Tue Dec 07, 2004 6:57 am
Posts: 285
Location: Nürnberg, Germany
1) You should not write Hibernate Code in a JSP ;-)

2) Please make sure that your Hibernate Mappings are contained in your WAR / EAR File

_________________
Please don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 01, 2006 7:21 am 
Newbie

Joined: Mon Oct 17, 2005 4:10 am
Posts: 6
anandbn wrote:
I think the query should be

Code:
from Empdata as empdata order by empid


Unless you use "as" to alias Hibernate would think the value is a mapped peristent class.



yes now i can list my values after changing they query as u said..thats right..

Thx & Rgds,
Jim.


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