annotations - JPA Lazy Fetch Custom Query -


i using jpa/jfreechart display data collected microcontroller, however, measure 14 sensors every 10 seconds. have been measuring on 2 months , have on 7000000 sets of data.

now actual problem, since don't want load 7000000 rows every time start program, want use average values minutes/hours. have thought of using namedquery don't know how keep relationship within , make jpa use since until loading of data has been done jpa itself. maybe can solve adding more annotations this?

@onetomany(mappedby="sensor") @orderby("timestamp asc") public list<value> getvalues() {     return this.values; } 

thanks in advance!

best regards

straight jpa not allow filtering results, since means entity's relationship no longer reflects in database, , have standardize behavior on done when adding entity relationship isn't in collection, exists in database.

the easiest way mapping though mark attribute @transient. can use method read values database using when needed, , cache them in entity if want.

many providers allow adding filters queries used bring in mappings, instance eclipselink allows setting @additionalcriteria on mapping described here: http://wiki.eclipse.org/eclipselink/development/additionalcriteria or can modify mapping directly shown here: http://wiki.eclipse.org/eclipselink/examples/jpa/mappingselectioncriteria


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -