views:

34

answers:

1

Hello,

I knew nHibernate does not support UNION. But there are some tricks, we can implement the same like :

  1. Using raw-sql
  2. Using sub-union class

I have an old application which is using <join table></join table> Now, I want to implement UNION here.

Here are the file(s) in application:

file: .hbm.xml

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"> 
<class name="">
<id name="Id" column="ID" type="Int32">
</id>
<!--Some properties are here -->    
<property name="" column=""/>
<!--Relations -->
<many-to-one name="" column="" lazy="false"/>
<bag name="" inverse="false" lazy="false" cascade="none">
  <key column="ID" />
  <one-to-many class="" />
</bag>
<join table="CAIMainDB.dbo.TClaimOnline">
  <key column="ID" foreign-key="ID"/>
  <property name="" column=""/>      
</join>
    </class>
</hibernate-mapping>

file: mapper.cs

<!-- Here I need to implement HQL or Raw SQL to achieve UNION -- >

file: Domain class

<!-- This contains the properties to set the aliases or map with columns -- >    
public virtual int Id { get; set; }

I appreciate if anyomne suggest me how to implement in the current scenario of my application.

A: 

Do you really need to do a union? If you're getting objects back from the database, then is it sufficient to concatenate the collections returned?

Neil Barnwell
@Neil:Could you please provide somemore info. I tried many scenarios but did not get the result?
Rick