OpenESPI-Common-java icon indicating copy to clipboard operation
OpenESPI-Common-java copied to clipboard

IntervalBlock JPA annotation in MeterReading Class

Open janad-lh opened this issue 11 years ago • 8 comments

Is it possible to manage relationship with IntervalBlock and MeterReading problematically not thorugh JPA. Having JPA relationship, lots of data is being loaded for Interval Block which is not always necessary.

janad-lh avatar Jun 02 '14 02:06 janad-lh

it is possible to avoid JPA, but I had attempted to use the lazy attribute to access the IntervalBlock collection on an as needed basis (i.e. I relied upon the lazy capabilities of JPA to mitigate the problem). Is it possible to refine that approach (or correct the implementation of it) and still maintain the JPA layer.

This issue will come back as we look at MongoDB as well I think, where we would like to heavily leverage the underlying time series capability of the persistent repository to our advantage.

jateeter avatar Jun 03 '14 20:06 jateeter

I believe this is an issue with the GAE repository. The MySQL implementation supports the LAZY characteristics to avoid this issue.

jateeter avatar Jul 07 '14 15:07 jateeter

I think the issue includes the observation that the IntervalBlock set from the API is fetched in its entirety before the query parameters associated with the request are applied and the result set filtered. I believe it makes sense to have the database query include the appropriate query parameters when the database is accessed. I could be wrong.

MartyBurns avatar Jul 07 '14 15:07 MartyBurns

Marty, I think there is another issue https://github.com/energyos/OpenESPI-Common-java/issues/123 that reflects this query parameter need. I believe this to be related more broadly to the JPA LAZY topic. Do you agreen?

jateeter avatar Jul 07 '14 15:07 jateeter

Can't be certain. Between the two issues are the two independent problems:

  1. The need for "lazy" behavior so all connected data is not fetched from database
  2. The need for query parameters to be applied as part of the database queries to leverage this database function and reduce the size of returned result sets.

MartyBurns avatar Jul 07 '14 15:07 MartyBurns

So to be clear - 1) this issue reflects the "lazy" behavior; and 2) issue https://github.com/energyos/OpenESPI-Common-java/issues/123 that reflects this query parameter need

jateeter avatar Jul 14 '14 14:07 jateeter

So for this issue, does GAE not support the JPA Lazy behaviors?

jateeter avatar Aug 04 '14 14:08 jateeter

I think we should move this to 1.3 RC 1 as we are having no success in finalizing the answer. It seems to me that JPA with lazy access is providing us the appropriate solution w/o having to directly use the query parameters at the repository level (i.e. that even tho we have done a DB access not restricted by query parameters within a transaction, b/c we do not reference any data outside the query parameter range, then we are only loading interval blocks/readings into memory if they are actually accessed during the export process. There is an inefficiency in the JPA management of the lazy access that could be removed. But I do not know how big a problem that is.

So, I propose we move this to 1.3 RC 1 and continue to monitor the actual operational behavior of the system.

thoughts?

jateeter avatar Aug 07 '14 14:08 jateeter