Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Database \ About Hibernate cache, you want the latest data have trouble even session.clear     - Binary search is really easy as you think you do (Programming)

- Linux System Tutorial: Ubuntu on the desktop is disabled by default keyring to unlock tips (Linux)

- Detailed software to run UnixBench (Linux)

- CentOS-based Kickstart automated installation practice (Linux)

- Java gets the current system time System.currentTimeMillis () (Programming)

- Linux installed PCRE (Linux)

- Linux regex sed detailing (Linux)

- Recover accidentally deleted Nginx logs (Server)

- Linux Apache server configure to protect system security (Linux)

- Log analysis is done with Grafana Elasticsearch (Server)

- Learning how to teach safety system to prevent your own IP leakage (Linux)

- C ++ Supplements - locates the new expression (Programming)

- Build Golang development environment configuration on Ubuntu 14.04 (Linux)

- Java by Spy Memcached to cache data (Programming)

- Linux Shell Scripting (Programming)

- Security: set limits on password (Linux)

- Upgrading to Debian 7.6 glibc 2.15 (Linux)

- learning Linux ls command examples (Linux)

- MongoDB configuration in Ubuntu 14.04 (Database)

- IP configuration under Linux (Linux)

 
         
  About Hibernate cache, you want the latest data have trouble even session.clear
     
  Add Date : 2018-11-21      
         
         
         
  One, hibernate cache
(1) hibernate supports two levels of cache, supports only the default cache;
(2) Each Session comes with a internal cache;
(3) When a Session is closed, the corresponding cache is automatically cleared;
(4) save, update, saveOrupdate, load, get, list, iterate, lock objects to the method will be stored in the cache.
(5) can be read from the cache data only: get, load, iterate
(6) Query objects by default do not read the cache, the cache if you want to support, they have passed the grammar:
query.setCacheable (true);
true
(7) After opening the query cache, only the query conditions identical to the previous query, will match the success in the cache.
(8) Criteria cache lack of support;
(9) a cache can not control the number of objects in the cache, the operation should pay attention when large quantities of data may cause memory overflow, can clear the cache.

     session.clear () to clear the cache for all objects
     session.evict (user) to clear the specified object
I have tried, session.clear () can be cleared away session.createQuery, but can not afford to clear session.createSQLQuery.
session.createSQLQuery is clear no one can not afford to, the following methods I have tried, no one so that the data is still wrong, the database is not the latest data:

        session.setFlushMode (FlushMode.AUTO);
        session.setCacheMode (CacheMode.NORMAL);
        session.flush ();
        session.clear ();
        sqlQuery.setCacheable (false);
The only way is cleared closed session. . . Silent, hibernate Is SB, SB, or I will not use? Is there a special clean-up session.createSQLQuery cached? This cache is a BUG can not afford to clean it?

Two, hibernate second level cache

save, update, saveOrupdate, load, get, list, query, Criteria method will fill the secondary cache
get, load, iterate will fetch data from the secondary cache
session.save (user) If user primary key "native" generation is not into the L2 cache.
(1) Turn the secondary cache

< Property name = "cache.use_second_level_cache"> true < / property>
(2) specifies the implementation class for the secondary cache hibernate

< Property name = "cache.provider_class">
    org.hibernate.cache.OSCacheProvider
< / Property>
(3) creating a profile for OSCache cache (required hibernate_Advance_Surpport_lib)
src / oscache.properties
Modify the configuration:
cache.capacity = 1000 Specifies the cache can accommodate the number of objects

(4) specify what classes need to put the secondary cache, need long-term use to only necessary objects into the second-level cache

< Class-cache class = "entity.PetInfo" usage = "read-only" /> // not allowed to update objects in the cache
< Class-cache class = "entity.PetInfo" usage = "read-write" /> // allow updating the object cache
Or in the orm file:

< Class name = "entity.PetInfo" table = "PetInfo" schema = "dbo" catalog = "epet">
   < Cache usage = "read-only" />
   ...
< / Class>

(5) If you need to clear the cache, use the following syntax

sessionFactory.evict (User.class) to clear all user
     
         
         
         
  More:      
 
- Linux system boot process detail (Linux)
- Java, on the dfile.encoding Systemproperty (Programming)
- Linux character device - automatically creates the device nodes and devices (Linux)
- Ubuntu in Vim editor display processing method Chinese garbled (Linux)
- A script to make your Ubuntu 14.04 Memory screen brightness (Linux)
- Vim useful plugin: YouCompleteMe (Linux)
- MySQL replication master and slave structure built (Database)
- Snort build a secure Linux server (Linux)
- SSL VPN SSL VPN access to security websites patron (Linux)
- Linux iptables firewall settings whitelist (RHEL 6 and CentOS 7) (Linux)
- Learning OpenCV: (VS2010-openCV2.4.3-win7 configuration instructions) (Linux)
- Let the router be your security barrier against external attack (Linux)
- Mongo-connector integrated MongoD to achieve incremental Solr index (Server)
- Linux - EXT2 file system is described in detail (Linux)
- Summary of Docker mounted directory (Server)
- Oracle 11g + RAC + RHEL6.5 + udev + ASM + PSU installation summary (Database)
- How to use the DM-Crypt encryption Linux File System (Linux)
- 30 Practical Linux system administrators will learn the command (Linux)
- using Docker Kitematic on windows (Linux)
- Java string equal size comparison (Programming)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.