Hibernate inner connection mapping - string where id

I would like to map the following sql to NHibernate. I need to make a separate object ie RoomTypeVO mapped to tb_tags in order to do this? Any help is greatly appreciated.

SELECT dbo.tb_rooms.id, dbo.tb_rooms.name, dbo.tb_tags.name AS 'roomType' FROM dbo.tb_rooms INNER JOIN dbo.tb_tags ON (dbo.tb_rooms.typeID = dbo.tb_tags.id)

<id name="id" column="id">

  <generator class="native" />

</id>

<property name="name" />

      

+1


source to share


2 answers


If you want a straight sql query, you don't need that. If you want to use HQL, you have to work with entity.

But you can always execute sql queries directly.



If you have a mapped object, you could just do something like this:

FROM RoomType 

      

+1


source


When you refer to "FROM" do you think of something like this?



<property name="totalPrice"
formula="( SELECT SUM (li.quantity*p.price) FROM LineItem li, Product p
            WHERE li.productId = p.productId
            AND li.customerId = customerId
            AND li.orderNumber = orderNumber )"/>

      

0


source







All Articles