Class JRJpaDataSource
- java.lang.Object
-
- net.sf.jasperreports.engine.data.JRAbstractBeanDataSource
-
- net.sf.jasperreports.jakarta.ejbql.JRJpaDataSource
-
- All Implemented Interfaces:
JRDataSource
,JRRewindableDataSource
public class JRJpaDataSource extends JRAbstractBeanDataSource
Java Persistence API data source that usesjakarta.persistence.Query.getResultList()
. The query result can be paginated by not retrieving all the rows at once. Fields are mapped to values in the result following these rules:- if the query returns a single object/bean (e.g.
SELECT m FROM Movie m
orSELECT NEW MovieDescription(m.title, m.genre) FROM Movie m
), then the fields are mapped to bean property names. - if the query returns multiple objects per row (e.g.
SELECT m.title, m.gender FROM Movie m
), the fields are mapped using the following syntax: COLUMN_index[.property], with the indexes starting from 1. Example mappings: COLUMN_1, COLUMN_2, COLUMN_2.title, COLUMN_2.movie.title.
- Author:
- Marcel Overdijk (marceloverdijk@hotmail.com)
- See Also:
JRJpaQueryExecuter.PROPERTY_JPA_QUERY_PAGE_SIZE
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interface
JRJpaDataSource.FieldValueReader
protected class
JRJpaDataSource.IndexPropertyReader
protected class
JRJpaDataSource.IndexReader
protected class
JRJpaDataSource.PropertyReader
-
Nested classes/interfaces inherited from class net.sf.jasperreports.engine.data.JRAbstractBeanDataSource
JRAbstractBeanDataSource.DefaultPropertyNameProvider, JRAbstractBeanDataSource.PropertyNameProvider
-
-
Field Summary
Fields Modifier and Type Field Description protected Object
currentRow
static String
EXCEPTION_MESSAGE_KEY_INDEX_OUT_OF_BOUNDS
-
Fields inherited from class net.sf.jasperreports.engine.data.JRAbstractBeanDataSource
CURRENT_BEAN_MAPPING, EXCEPTION_MESSAGE_KEY_BEAN_FIELD_VALUE_NOT_RETRIEVED, PROPERTY_JAVABEAN_FIELD_PROPERTY, propertyNameProvider
-
-
Constructor Summary
Constructors Constructor Description JRJpaDataSource(JRJpaQueryExecuter queryExecuter, int pageSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
fetchPage()
Object
getFieldValue(JRField field)
Gets the field value for the current position.protected JRJpaDataSource.FieldValueReader
getFieldValueReader(JRField field)
void
moveFirst()
Moves back to the first element in the data source.boolean
next()
Tries to position the cursor on the next element in the data source.-
Methods inherited from class net.sf.jasperreports.engine.data.JRAbstractBeanDataSource
getBeanProperty, getFieldValue, getPropertyName, isCurrentBeanMapping
-
-
-
-
Field Detail
-
EXCEPTION_MESSAGE_KEY_INDEX_OUT_OF_BOUNDS
public static final String EXCEPTION_MESSAGE_KEY_INDEX_OUT_OF_BOUNDS
- See Also:
- Constant Field Values
-
currentRow
protected Object currentRow
-
-
Constructor Detail
-
JRJpaDataSource
public JRJpaDataSource(JRJpaQueryExecuter queryExecuter, int pageSize)
-
-
Method Detail
-
fetchPage
protected void fetchPage()
-
next
public boolean next()
Description copied from interface:JRDataSource
Tries to position the cursor on the next element in the data source.- Returns:
- true if there is a next record, false otherwise
-
moveFirst
public void moveFirst()
Description copied from interface:JRRewindableDataSource
Moves back to the first element in the data source.
-
getFieldValue
public Object getFieldValue(JRField field) throws JRException
Description copied from interface:JRDataSource
Gets the field value for the current position.- Returns:
- an object containing the field value. The object type must be the field object type.
- Throws:
JRException
-
getFieldValueReader
protected JRJpaDataSource.FieldValueReader getFieldValueReader(JRField field)
-
-