-->
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: uniqueResult Casting Exception
PostPosted: Tue Oct 25, 2005 11:01 pm 
Beginner
Beginner

Joined: Mon Sep 19, 2005 3:59 pm
Posts: 31
Hi there,

the enclosed code always throws the exception java.lang.ClassCastExceptionon line

resultSet = (Systemuser) query.uniqueResult();

Could you please give me some ideas?

Any advice is highly appreciated.

Lamborghini


Code:
   public Systemuser login(String userName, String password) {


      Session session = null;


      Transaction tx = null;

      Systemuser systemuser= null;
      try {


         session = HibernateSessionFactory.currentSession();

         tx = session.beginTransaction();

         Query query = session
               .createQuery("from Systemuser where username = :UserName and pin = :Password");
         query.setParameter("UserName", userName);
         query.setParameter("Password", password);
         systemuser= (Systemuser) query.uniqueResult();

         tx.commit();
      } catch (HibernateException he) {
         he.printStackTrace();


         if (tx != null)
            try {
               tx.rollback();
            } catch (HibernateException he1) {
               he1.printStackTrace();
            }
      } finally {
         try {
            if (session != null)
               session.close();
         } catch (HibernateException he1) {
            he1.printStackTrace();
         }
      }
      return systemuser;
   }


Top
 Profile  
 
 Post subject: Different classes
PostPosted: Wed Oct 26, 2005 6:27 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
Could it be that Sustemuser class exists in different packages and the one imported in Java code is not the same as specified in hbm mappings?

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


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.