But it only exports the data that is being displayed on the GUI rather than exporting the whole table data (of an entity). Like, when the user only wants to the 20 records on the GUI, my ‘export’ function should export every record of the entity nevertheless.
I thought of writing a service that uses the entity manager, but this approach has the disadvantage that I would have to implement a SQL-query for every database supported. Generally, it would be better if I could leave this to Cuba.
Under the Administration menu item in your app, there is an item called “Entity Inspector”. From here you can choose the Entity you want to view. This populates a table with all instances of that Entity. You can then hit the “Excel” button. This also limits the exported data to the items currently loaded into the table, but from the filter you can choose to show 5000 rows at a time which should be ample in most applications.
I thought of writing a service that uses the entity manager, but this approach has the disadvantage that I would have to implement a SQL-query for every database supported.
You don’t have to write SQL, you’ll have to write JPQL once ant it will work for all databases. In the project you mentioned there is a method that exports a collection of entities. Its single argument is that collection. As I understand your question is how to get a full collection of entities of specific type? You can use the DataManager for that. The following code should work: