Let\'s say I have a table with millions of rows. Using JPA, what\'s the proper way to iterate over a query against that table, such that I don\'t have all an in-memo
To expand on @Tomasz Nurkiewicz's answer. You have access to the DataSource which in turn can provide you with a connection
@Resource(name = "myDataSource",
lookup = "java:comp/DefaultDataSource")
private DataSource myDataSource;
In your code you have
try (Connection connection = myDataSource.getConnection()) {
// raw jdbc operations
}
This will allow you to bypass JPA for some specific large batch operations like import/export, however you still have access to the entity manager for other JPA operations if you need it.