-->
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: unit testing when mapping has 'where' clause with sysdate
PostPosted: Wed Oct 31, 2007 4:41 am 
Newbie

Joined: Wed Oct 31, 2007 4:17 am
Posts: 1
I am using Hibernate 2 and have the following property mapping which has a WHERE clause that filters on 'sysdate' to return the first period after todays date.

<set name="currentPeriod"
cascade="none"
access="field"
lazy="true"
where="period_date = (SELECT MIN(p1.period_date) FROM period p1 WHERE p1.period_date > sysdate AND p1.company_id = company_id)">
<key>
<column name="COMPANY_ID"/>
</key>
<one-to-many class="common.Accounts.Period"/>
</set>

My problem is in unit testing using this class.
Within the Java application I can change todays date for testing purposes but I can't change 'sysdate' in my tests which in this case is the Oracle databases today date.

I imagine it is not possibe to parameterize the SQL in the WHERE clause and pass a date at runtime from my unit test?

Would anyone have any suggestions of an alternative approach here?


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.