You can use property-ref on the key to join using any property. Diego
On Sat, May 1, 2010 at 01:37, Jim Geurts <[email protected]> wrote: > I have a map file that corresponds to a sql view. I'd like to join > another table with it as a bag, but the bag assumes that I want to > join on the primary key of the view. I'd like to join on a different > column, but can't seem to figure out how to do this. > > My map file looks like: > > <class name="UnitSummary" table="UnitSummaries"> > <id name="Id" column="UnitId"> > <generator class="identity" /> > </id> > <property name="Name" /> > <property name="LeaseId" /> > > <bag name="Tenants" table="Tenant_Lease_Map" fetch="join"> > <key column="LeaseId" /> > <many-to-many class="Tenant" column="TenantId" /> > </bag> > </class> > > This results in something that looks like: > > SELECT this_.UnitId as UnitId22_1_, > this_.Name as Name22_1_, > this_.LeaseId as LeaseId22_1_, > tenants2_.LeaseId as LeaseId3_, > tenant3_.TenantId as TenantId3_, > tenant3_.TenantId as TenantId6_0_, > tenant3_.Name as Name6_0_, > FROM UnitSummaries this_ > left outer join Tenant_Lease_Map tenants2_ > on this_.UnitId = tenants2_.LeaseId > left outer join Tenants tenant3_ > on tenants2_.TenantId = tenant3_.TenantId > > > > > Rather than joining Tenant_Lease_Map on the UnitId, I would like to > join it on the LeaseId column of the UnitSummaries table. Is this > possible? > > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<nhusers%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
