Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
[b]Hibernate version:3.1
Hello All,
I have the following classes (I don't think the interfaces are important but I've included them nonetheless).
NotificationImpl implements Notification
SourceNotificationImpl implements SourceNotification extends NotificationImpl
EventImpl implements Event
SourceNotificationImpl is a joined subclass of Notification. Here's a snippet of the mapping:
<class name="NotificationBase" table="NOTIFICATIONS">
...
<many-to-one
name="event"
class="com.invoqsystems.apex.model.event.EventImpl"
column="EVENT_ID"
not-null="true"
cascade="all"
/>
...
<joined-subclass
name="com.invoqsystems.apex.model.notifications.source.SourceNotificationImpl"
table="SOURCE_NOTIFICATIONS">
...
</joned-subclass>
...
</class>
Here's a snippet of the parent (Event) mapping:
<class name="EventImpl" table="EVENTS" proxy="Event">
...
<set name="notifications"
table="NOTIFICATIONS"
inverse="false"
cascade="all">
<cache usage="read-write"/>
<key column="EVENT_ID"/>
<one-to-many class="com.invoqsystems.apex.model.notifications.source.SourceNotificationImpl"/>
</set>
...
</class>
What I expect is that an EventImpl object will get the SourceNotificationImpls it's associated with. Unfortunately I get the following exception when in code I try to add a SourceNotificationImpl to an Event:
java.sql.SQLException: ORA-00904: "NOTIFICATI0_"."EVENT_ID": invalid identifier
Here's the generated SQL:
select notificati0_.EVENT_ID as EVENT9_6_, notificati0_.NOTIFICATION_ID as NOTIFICA1_6_, notificati0_.NOTIFICATION_ID as NOTIFICA1_46_5_, notificati0_1_.CATEGORY as CATEGORY46_5_, notificati0_1_.CREATION_DATE as CREATION3_46_5_, notificati0_1_.EVENT_ID as EVENT4_46_5_, notificati0_.STATE as STATE47_5_, notificati0_.LAST_UPDATE_RECIPIENT_ID as LAST3_47_5_, notificati0_.LAST_UPDATE_DATE as LAST4_47_5_, notificati0_.CURRENT_MEM_ORDER as CURRENT5_47_5_, notificati0_.PRIORITY as PRIORITY47_5_, notificati0_.PRESENTATION_SCRIPT_ID as PRESENTA7_47_5_, notificati0_.RESPONSE_SCRIPT_ID as RESPONSE8_47_5_, notificati0_.EVENT_ID as EVENT9_47_5_, notificati0_.SUBSCRIPTION_ID as SUBSCRI10_47_5_, notificati0_.TIMEFRAME_OVERRIDE as TIMEFRAME11_47_5_, notificati0_.USE_EMERGENCY as USE12_47_5_, notificati0_.ESCALATION_OVERRIDE as ESCALATION13_47_5_, notificati0_.HANDLE_DELIVERY_EVENTS as HANDLE14_47_5_, script1_.ID as ID128_0_, script1_.NAME as NAME128_0_, script1_.NOTES as NOTES128_0_, script1_.CODE as CODE128_0_, script1_.VERSION_ID as VERSION5_128_0_, (select ST.NAME from SCRIPT_TYPES ST where ST.ID=script1_.TYPE) as formula0_0_, scriptpack2_.ID as ID139_1_, scriptpack2_.VERSION as VERSION139_1_, scriptpack2_.NOTES as NOTES139_1_, scriptpack2_.PACKAGE_ID as PACKAGE4_139_1_, (select ST.NAME from STATUS_TYPES ST where ST.ID=scriptpack2_.STATUS) as formula2_1_, scriptpack3_.ID as ID138_2_, scriptpack3_.NAME as NAME138_2_, scriptpack3_.DESCRIPTION as DESCRIPT3_138_2_, (select PT.NAME from PACKAGE_TYPES PT where PT.ID=scriptpack3_.TYPE) as formula1_2_, script4_.ID as ID128_3_, script4_.NAME as NAME128_3_, script4_.NOTES as NOTES128_3_, script4_.CODE as CODE128_3_, script4_.VERSION_ID as VERSION5_128_3_, (select ST.NAME from SCRIPT_TYPES ST where ST.ID=script4_.TYPE) as formula0_3_, genericnot5_.COMMODITY_ID as COMMODITY1_10_4_, genericnot5_.COMMODITY_NOTIFICATION_ID as COMMODITY5_10_4_ from SOURCE_NOTIFICATIONS notificati0_ inner join NOTIFICATIONS notificati0_1_ on notificati0_.NOTIFICATION_ID=notificati0_1_.NOTIFICATION_ID left outer join SCRIPTS script1_ on notificati0_.PRESENTATION_SCRIPT_ID=script1_.ID left outer join SCRIPT_PACKAGE_VERSIONS scriptpack2_ on script1_.VERSION_ID=scriptpack2_.ID left outer join SCRIPT_PACKAGES scriptpack3_ on scriptpack2_.PACKAGE_ID=scriptpack3_.ID left outer join SCRIPTS script4_ on notificati0_.RESPONSE_SCRIPT_ID=script4_.ID left outer join COMMODITIES genericnot5_ on notificati0_.NOTIFICATION_ID=genericnot5_.COMMODITY_NOTIFICATION_ID and genericnot5_.COMMODITY_TYPE='GENERIC_NOTIFICATION' where notificati0_.EVENT_ID=?
That's a mess, but the pertinent fact is that the query expects EVENT_ID to be part of the SOURCE_NOTIFICATIONS table rather than the NOTIFICATIONS table (that's where it is). Is there something wrong with my mappings, or am I misunderstanding how things are supposed to work? Any help would be greatly appreciated.
Thanks,
Tobias