-->
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: Discriminator column not found when querying DB
PostPosted: Sat Feb 16, 2013 11:38 am 
Newbie

Joined: Wed Oct 24, 2012 12:51 pm
Posts: 3
Hi,
I have a class called Device, and because I use inheritance, I had to add a discriminator in the mapping file like this:
Code:
   <class name="Device" table="devices">
      <id name="deviceId" column="deviceid">
         <generator class="increment"></generator>
      </id>
      
      <discriminator column="classType" type="string"></discriminator>



This obviously creates a new column in the devices table called "classType". Now, I need to create a query like this:
Code:
         String query = "select l.linkid,l.deviceId,l.actionId,l.status " +
                     "from actionlinks l, devices d, actions a " +
                     "where l.deviceId=d.deviceid and l.actionId=a.actionid";
         actionList = (List<ActionLink>) session.createSQLQuery(query)
               .addEntity("link", ActionLink.class)
               .addJoin("dev","link.device")
               .addJoin("act", "link.action")
               .list();


The sctucture of the ActionLink class is as follows:
ActionLink:
int linkId
Device device
Action action
String status

When I try to run this query, I get the following error:
Quote:
15:19:59,131 WARN SqlExceptionHelper:143 - SQL Error: 0, SQLState: S0022
15:19:59,132 ERROR SqlExceptionHelper:144 - Column 'classType' not found.
org.hibernate.exception.SQLGrammarException: Column 'classType' not found.


That's because the "Device" class does not have such a property called "classType". but the column is in the devices table. Is there any way how to overcome this problem?

Thanks for any help
Dave


Top
 Profile  
 
 Post subject: Re: Discriminator column not found when querying DB
PostPosted: Sat Feb 16, 2013 12:41 pm 
Newbie

Joined: Wed Oct 24, 2012 12:51 pm
Posts: 3
Never mind, I found an easier way to do what I needed. :)


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.