Monday, March 21, 2016

Design Pattern and LRUCache

hibernate improve database performance

hibernate improve database performance


  1. In the query string, you should use jdbc placeholder? Or use named parameters: Do not use the query string value instead of the very values.
  2. Flush affect performance, frequently refreshed affect performance, minimize unnecessary refresh. 
  3. Cascade strategy, a few to several relationships set correctly cascade strategy, to think clearly in the operation target A cascade operation, while the need for an object B, such as one to many relationship between father and son, the father removed one, required level United delete child many, this time can be set to one end of this cascade = "delete", so when you delete one, the child is automatically deleted, but the pair does not affect the parent. Cascade has other property values, as long as the settings are correct, you can improve performance. 
  4. Lazy policy set correctly delay loading strategy will also enhance the performance, one to many or many to many, the total delay should normally be loaded into the memory of many of the party. Set lazy = "true", first send sql statements to load itself into memory only when needed to load Cascading objects; lazy = "false", is simultaneously loaded into memory objects themselves and cascade. 
  5. In addition to the performance of the collection (set, list, map, array ), should be set up correctly. 
  6.  The proper use of third-party cache, read frequently writes small operating conditions, the use of third-party cache can significantly improve performance, such as ehcache caching strategies have: read-only, read-write and notstrict-read-write.

Friday, March 18, 2016

Good links for performance

ArrayList equals for list of array

Omio Bani


  1. http://stackoverflow.com/questions/36069596/java-how-to-convert-string-to-string-with-different-charset


A string doesn't have an encoding - or it's always UTF-16, if you want to think of it like that. There's no such thing as "a UTF8 string". If you've converted some binary data into a String using the wrong encoding, you're in trouble already


  1. http://stackoverflow.com/questions/36063803/why-the-containvalue-method-returning-true-even-if-i-override-the-hashcode-met

Hash maps only use hash codes to find keys efficiently. When you ask the map to find a value, it basically has to iterate over all its entries, at which point there's no point in using hashCode(), so it just calls equals.
If you try the map the other way round, with Test as the key instead of the value, that won't work without overriding hashCode.

Java Garbase collection basics