-->
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: polymorphism
PostPosted: Wed Mar 10, 2004 1:32 pm 
Pro
Pro

Joined: Mon Sep 08, 2003 4:30 pm
Posts: 203
I have class NEMgmtInfoC which extends NEMgmtInfo.
In the mapping NEMgmtInfo has polymorphism=implicit.

The following code throws ClassCastExeption on the line in bold:

Code:
   public NEMgmtInfo[] getAllDevices() throws DAOException {
      Query q = null;
      List newList = null;
      try {
         q =
            sess.getPersistentSession().createQuery(
               "from com.db.device.NEMgmtInfo as mgmt");
         newList = q.list();
      } catch (HibernateException e) {
         throw new DAOException(e);
      }

      NEMgmtInfoC[] devices = new NEMgmtInfoC[newList.size()];
      for (int i = 0; i < newList.size(); ++i) {
         [b]devices[i] = (NEMgmtInfoC) newList.get(i);[/b]      }

      return devices;
   }


Bassically, I want the query to give me NEMgmtInfoC objects.

Please help.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2004 1:43 pm 
Newbie

Joined: Tue Mar 09, 2004 8:57 am
Posts: 12
Location: Argentina
you forgot the bold line...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2004 1:50 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Why don't you just query for them? from com.db.device.NEMgmtInfoC as mgmt


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2004 2:12 pm 
Beginner
Beginner

Joined: Thu Feb 05, 2004 10:39 pm
Posts: 44
unfortunately bolding does not work inside of other tags.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 10:10 am 
Beginner
Beginner

Joined: Tue Nov 11, 2003 4:49 am
Posts: 47
Location: Florence, Italy
You forgot the mappings.

_________________
Ciao.


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.