Search code examples
javahibernateormmappingentity

Entity mapping without Hibernate (JPA)


Need to read Java entities from database. The database choice is uncertain for now so need my code to be DB-independent. Hibernate provides enough such independency but it (as I can see) is mostly purposed for front-end. The problem is that it returns collections that are first cached on client side. My application needs reading large amount of objects for processing them in one pass. Using pure JDBC with ResultSet is more appropriate for this but it involves quite much boilerplate code with native SQL.

Woud like your suggestions about the solution. See it something like this: we define JPA entities, then read them from DB in an iterating manner using creteria in, for example, HQL. And the entities mustn't be collected on the client side before the iteration is started (except, probably, some buffering for performance reason).

Would also concider Java solutions not based on Hibernate/JPA.


Solution

  • As per your use case compare the supported API for JDBC in below link comparing JDBC API