-->
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.  [ 2 posts ] 
Author Message
 Post subject: Filter on calculated properties?
PostPosted: Sun Aug 24, 2008 10:05 am 
Newbie

Joined: Tue Jul 29, 2008 10:53 am
Posts: 11
Introduction
Let's say I have this table:

Code:
Contracts
-------------
ID
CustomerID
DateLastPayment
Valid


And this is my object:

Code:
Contract
-------------
ID
CustomerID
LastPaymentDate
Valid
IsOverdue


As you can see, my object has one property more than my table: IsOverdue
This property is calculated with this method:

Code:
public virtual bool IsOverdue
{
   get
   {
      if (Valid && LastPaymentDate < System.DateTime.Now.AddDays(-31) )
      {
         return true;
      }
      else
      {
         return false;
      }
   }
}



Question
I would like to know if it's possible to use Nhibernate to get all contract which are overdue. I mean, all contract for which IsOverdue == true.

Offcourse I know how to do this with SQL:

Code:
select * from Contracts
where Valid = 1 and ( DateLastPayment< dateadd(dd,-31, GETDATE() ) )


But is there a way to use the property IsOverdue on the object with Nhibernate?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 25, 2008 1:57 am 
Regular
Regular

Joined: Tue Jul 29, 2008 3:30 am
Posts: 74
You could try the "formula" attribute of a property mapping.
But I have never used this, so I don't know if it will work.


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

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.