Hi all!
I want to use some classes to query statistical data. These classes are only filled by named queries. On program start, i let NHibernate tools automatically update the schema for me, wich i consider very convenient. Now I cant keep this procedure from generating a table for my query-classes. Are there any options in the mapping-files I overlooked? Or is there any way to tell those tools to leave out specific classes?
Here is the mapping file:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Finance.Core" namespace="REF.Finance.Core.DataObject">
<!-- the class definition -->
<class name="BookingStatistic" mutable="false">
<cache usage="read-only" />
<composite-id>
<!-- include the values since it seems impossible to disable caching -->
<key-many-to-one name="Account" column="Account" class="Account" />
<key-property name="Date" column="Date" type="DateTime" />
<key-property name="Amount" column="Amount" type="float" />
<key-property name="Average" column="Average" type="float" />
</composite-id>
</class>
<!-- query monthly statistic values -->
<sql-query name="BookingStatistic.Monthly" cacheable="false" cache-mode="ignore" read-only="true">
<return class="BookingStatistic" lock-mode="none" />
<![CDATA[
with source as
(
select bkg_acc_id,
cast(cast(year(bkg_reportdate) as nvarchar) + right('0' + cast(month(bkg_reportdate) as nvarchar), 2) + '01' as datetime) as bkg_reportdate,
bkg_amount
from booking
where bkg_acc_id = :account
and bkg_reportdate >= dateadd(month, -:avgMonth, :fromDate)
and bkg_reportdate <= :toDate
),
aggregate as
(
select bkg_acc_id,
bkg_reportdate,
sum(bkg_amount) as bkg_amount
from source
group by bkg_acc_id,
bkg_reportdate
),
movingAverage as
(
select bk1.bkg_acc_id,
bk1.bkg_reportdate,
avg(bk2.bkg_amount) as Average
from aggregate as bk1
inner join aggregate as bk2
on bk2.bkg_acc_id = bk1.bkg_acc_id
and bk2.bkg_reportdate >= dateadd(month, -:avgMonth, bk1.bkg_reportdate)
and bk2.bkg_reportdate <= bk1.bkg_reportdate
group by bk1.bkg_acc_id,
bk1.bkg_reportdate
)
select bk1.bkg_acc_id as Account,
bk1.bkg_reportdate as Date,
bk1.bkg_amount as Amount,
bk2.Average as Average
from aggregate as bk1
inner join movingAverage as bk2
on bk2.bkg_acc_id = bk1.bkg_acc_id
and bk2.bkg_reportdate = bk1.bkg_reportdate
where bk1.bkg_reportdate >= :fromDate
and bk1.bkg_reportdate <= :toDate
order by bk1.bkg_reportdate
]]>
</sql-query>
</hibernate-mapping>
Greetings!
Zorgoban