D
D
Dmitry2014-07-15 13:22:39
Java
Dmitry, 2014-07-15 13:22:39

How to implement SQL query caching for different table views in one place (Java+SWT/JFace+Hibernate)?

Hello. And so before me is worth approximately the next task.
There are several tables in the Desktop application. All of them display data from one table in the database, but differ in the set of selected columns for display and the criteria for selecting records (and, as a result, in different rows). And there is a desire (perhaps not rational) to cache the requested data in one model, storing row and column numbers for each view.
What you should pay attention to. Data should be deleted over time. However, when an entry serves as a cache for two or more views, it should be possible to remove only those columns that are out of date for a particular view. In this case, the criterion for removal should be not only time, but also a certain condition.
Work with this is carried out using Hibernate, in which I still understand poorly. And the table is displayed in TableViewer (SWT/JFace).
Hence the questions:
Are there ready-made solutions for such an architecture, or useful tools for this?
Is it rational to do this, if most likely the rows will be frequently requested repeatedly?
What can be read? I read about different caching methods - these are all common words and do not help in solving.
In the Google Guava library, I found the Cache and LoadingCache classes, which partially solve the problem. But there are some contradictions:
1) rows are deleted only due to obsolescence, without the possibility of setting an additional condition, for example, forcibly leaving it in the cache, even if the data is obsolete;
2) the entire line is deleted, even though the entry may be out of date for one representation and not out of date for another.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Cheremisin, 2014-07-15
@leahch

Firstly, the query cache and the application data cache, perhaps the cache of the rendered parts of the page, are completely different things, which, it seems to me, you mixed together.
1) hibernate has its own query cache, which is configured in a bunch of different ways to work with different caches. O! There is even a habra-article - habrahabr.ru/post/135176
2) Deprecation of records and so on is the prerogative of the database cache
3) If some data should be deleted over time, that is, LRU-type policies, for the data cache, perhaps you will have to use not only the query cache, but also the cache of rendered pages.
From the article on Habré you will find a description of the main caching libraries ...

B
bazarnazar, 2014-08-28
@bazarnazar

If the first-level cache is sufficient (it works within one session), then nothing needs to be done. If you need a second level (at the SessionFactory), then take some cache implementation for hibernate like ehcache, infinispan, hazelcast, and so on, and turn it on. Here's a good guide for ehcache
PS Why do you need updatable displays if they differ only in the selection of columns? leave everything in one table, and create several different entities for one table with the necessary fields in each. unload base from updatetable view

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question