Create a mapping similar to following. SQL can be as complex as you need. Remember that the id must be unique for each row returned.
Code:
<hibernate-mapping>
<class name="TestView">
<id name="id" type="long">
<generator class="assigned" />
</id>
<property name="value1" update="false" insert="false" type="string" />
</class>
<sql-query name="query1">
<![CDATA[
SELECT 1 AS {tv.id}, 'value' AS {tv.value1} FROM dual
]]>
<return alias="tv" class="TestView"/>
</sql-query>
</hibernate-mapping>
Add reference to this mapping to configuration.
Create a POJO that corresponds to the mapping.
You should be able to execute using something like this:
Code:
List results = session.getNamedQuery("query1").list();
This should work -- I used this extensively with H2 prior to moving to H3.
Curtis ...