473,386 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Retrieve list items

I have a problem with getting the list items, below is my hibernate code, after that code there is my method ..and below that is my junit test. How can I make sure that query is executing properly, and how can I check that results actually work .. this query should return couple of pids .. and put them in the list.. now I'm 90 % sure that my list is always empty .. instead it should have 3 pids : 4573, 4593, 4693 .. can anyone figure it out what I'm doing wrong .. why the pids are not inside my list ..

Expand|Select|Wrap|Line Numbers
  1. <sql-query name="endDateChecker">
  2. <return-scalar column="PId" type="java.lang.Long"/>
  3. <![CDATA[select
  4.               pid as PId 
  5.               from  
  6.               info       
  7.               where   
  8.              end_date < trunc(sysdate)]]>     
  9. </sql-query>
<-HIBERNATE->

Expand|Select|Wrap|Line Numbers
  1. public List<Long> findItemByPIdEndDate() throws ROSException {                
  2.  
  3. List<Long> list = null;     
  4.            try{                   
  5.      Session session = sessionFactory.getCurrentSession();                           
  6.  
  7. Query query = session.getNamedQuery("endDateChecker");                        
  8.  
  9. list = query.list();                      
  10.   for (Long long1 : list) {                           
  11.      logger.info(long1);                    
  12.     }               
  13.  }catch (HibernateException e){    
  14.                     throw new DataAccessException(e.getMessage());                
  15.  
  16. }               
  17.  return list;       
  18.  }
<-METHOD->

Expand|Select|Wrap|Line Numbers
  1. public class FindItemByPIdEndDateTest{        
  2. private static final Log logger = ROSLogFactory.getLog(FindItemByPIdEndDateTest.class);       
  3. private ApplicationContext beanFactory;        
  4. private  PersistenceMngt lps = null;        
  5. @Before        
  6. public void setUp() throws Exception {               
  7.  beanFactory = new ClassPathXmlApplicationContext("/resources/ros-conf/engine-conf/applicationContext.xml");                
  8. lps = (PersistenceMngt)beanFactory.getBean("persistenceMngtService");        
  9.  
  10. }       
  11. @After       
  12.  public void tearDown() throws Exception {        
  13. }        
  14. @Test       
  15.  public void testFindItemByPIdEndDate(){         
  16.        List<Long> itemdb = null;              
  17.   try {                       
  18.  itemdb = lps.findLroByPIdEndDate(); //          
  19.   assertNull("List is empty", itemdb);//                     
  20.   assertEquals(4573, itemdb.indexOf(0));//                    
  21.   assertEquals(3, itemdb.size());//    
  22.   assertEquals(4593, itemdb.indexOf(1));//       
  23.   assertEquals(4693, itemdb.indexOf(2));                
  24. } catch (ROSException e) {             
  25.            e.printStackTrace();   
  26.            fail(e.getMessage());            
  27.     }                   
  28. }}
<-TEST->
Oct 20 '09 #1
0 2046

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Xiru | last post by:
I would like to retrieve the value from a DataList on postback. I can read the ItemIndex and values from a child TextBox but not cannot seem to find a way to read a databound item on the datalist....
0
by: Brian Henry | last post by:
Since no one else knew how to do this I sat here all morning experimenting with this and this is what I came up with... Its an example of how to get a list of items back from a virtual mode list...
7
by: Flavio | last post by:
Hi, I have a QListview widget that allows me to store a bunch of strings in it. This strings can be visualized, sorted, selected, etc. My Problem is that I cant find a way to get the user...
4
by: serge | last post by:
http://www.csharphelp.com/archives2/archive342.html I am using the sample code from this link but I am unable to figure out how to retrieve the list of the User-Defined Functions. I am able to...
3
by: dfetrow410 | last post by:
I need make a comma seperated list, but whwn I build the list I get a comma at the end. How do I remove it? foreach (ListItem lst in REIPropertyType.Items) { if (lst.Selected == true) {...
6
by: Daz | last post by:
Hi everyone. Firstly, I apologise if this i not what you would call a PHP problem. I get quite confused as to what lives in which realm, so if this shouldn't be posted here, please suggest where...
3
by: JimCinLA | last post by:
I use a place holder to load different user controls on an .aspx page. Let's call this default.aspx. Each user controls contains about a dozen different ASP.Net controls. My question is, how...
1
by: divya | last post by:
Hello, I used the below code to move selected items between two listboxes Left and Right:- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestPopup.aspx.cs" Inherits="TestPopup" %> ...
3
by: mistersulu | last post by:
Hi all: I'm using a wx.ListView object with a multi-threaded wxPython app. The list is dynamically generated and accessed across two or more threads. In spite of the fact that I have checks to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.