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