1 28 package net.sf.jasperreports.engine.data; 29 30 import org.hibernate.ScrollableResults; 31 32 import net.sf.jasperreports.engine.JRException; 33 import net.sf.jasperreports.engine.JRRewindableDataSource; 34 import net.sf.jasperreports.engine.query.JRHibernateQueryExecuter; 35 36 42 public class JRHibernateScrollDataSource extends JRHibernateAbstractDataSource implements JRRewindableDataSource 43 { 44 private ScrollableResults scrollableResults; 45 46 public JRHibernateScrollDataSource(JRHibernateQueryExecuter queryExecuter, boolean useFieldDescription) 47 { 48 super(queryExecuter, useFieldDescription, true); 49 50 scrollableResults = queryExecuter.scroll(); 51 } 52 53 public boolean next() throws JRException 54 { 55 if (scrollableResults != null && scrollableResults.next()) 56 { 57 setCurrentRowValue(scrollableResults.get()); 58 return true; 59 } 60 61 return false; 62 } 63 64 public void moveFirst() 65 { 66 queryExecuter.closeScrollableResults(); 67 scrollableResults = queryExecuter.scroll(); 68 } 69 } 70 | Popular Tags |