Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 2.0.0.1001
Mapping documents:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
namespace="Panther.Schedule"
assembly="panther.sched.nhibernate">
<class name="Panther.Scheduling.ScheduledQuery, panther.sched.nhibernate"
table="MessageScheduleRecurrenceQuery" >
<id name="ScheduleRecurrenceId" access="Panther.Scheduling.NHibernate.MUnderBarPropertyAccessor, panther.sched.nhibernate"
column="ScheduleRecurrenceID"
type="Int32">
<generator class="assigned"/>
</id>
<property name="ScheduleRecurrenceId" access="Panther.Scheduling.NHibernate.MUnderBarPropertyAccessor, panther.sched.nhibernate"/>
<property name="SendOnEmpty" access="Panther.Scheduling.NHibernate.MUnderBarPropertyAccessor, panther.sched.nhibernate"/>
<property name="SendOnError" access="Panther.Scheduling.NHibernate.MUnderBarPropertyAccessor, panther.sched.nhibernate"/>
<set name="Parameters" access="Panther.Scheduling.NHibernate.MUnderBarPropertyAccessor, panther.sched.nhibernate">
<key property-ref="ScheduleRecurrenceId"/>
<one-to-many class="Panther.Scheduling.ScheduledQuery+Parameter, panther.sched.nhibernate" />
</set>
<join table="ScheduledQueryLib">
<key column="ScheduledQueryID" foreign-key="ScheduledQueryID" property-ref="ScheduledQueryId"/>
<property name="Name" access="Panther.Scheduling.NHibernate.MUnderBarPropertyAccessor, panther.sched.nhibernate"/>
<property name="ProcedureName" access="Panther.Scheduling.NHibernate.MUnderBarPropertyAccessor, panther.sched.nhibernate"/>
</join>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
using (tx = session.BeginTransaction ())
{
return session.Get <ScheduledQuery> (pk);
}
Name and version of the database you are using: MsSql2005
The generated SQL (show_sql=true):
SELECT scheduledq0_.ScheduleRecurrenceID as Schedule1_4_0_, scheduledq0_.SendOnEmpty as SendOnEm2_4_0_, scheduledq0_.SendOnError as SendOnEr3_4_0_, scheduledq0_1_.Name as Name5_0_, scheduledq0_1_.ProcedureName as Procedur3_5_0_ FROM MessageScheduleRecurrenceQuery scheduledq0_ inner join ScheduledQueryLib scheduledq0_1_ on scheduledq0_.ScheduleRecurrenceID = scheduledq0_1_.ScheduledQueryID WHERE scheduledq0_.ScheduleRecurrenceID=?
I was hoping for this to actually generate:
SELECT scheduledq0_.ScheduleRecurrenceID as Schedule1_4_0_, scheduledq0_.SendOnEmpty as SendOnEm2_4_0_, scheduledq0_.SendOnError as SendOnEr3_4_0_, scheduledq0_1_.Name as Name5_0_, scheduledq0_1_.ProcedureName as Procedur3_5_0_ FROM MessageScheduleRecurrenceQuery scheduledq0_ inner join ScheduledQueryLib scheduledq0_1_ on scheduledq0_.[b]ScheduledQueryID[\b]=scheduledq0_1_.ScheduledQueryID WHERE scheduledq0_.ScheduleRecurrenceID=?
If I change it to that and run it in Server Management Studio, it comes back with a result, but without the change I get nothing. This is because ScheduledQueryID on the MessageScheduleRecurrenceQuery table is a foreign key into the ScheduledQueryLib table but the <join> tag seems to be assuming that it goes the other way.
Does anyone have any ideas on how to achieve the desired behavior?