These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: How to avoid creation of a table?
PostPosted: Thu Feb 12, 2009 5:00 am 
Beginner
Beginner

Joined: Sat Jan 26, 2008 6:33 am
Posts: 24
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.