In the Preferences, under Java -> Editor -> Content Assist -> Advanced that Java proposals
Just click on java proposals.
Category Archives: JAVA
First Level cache and second level cache in hibernate
First Level Cache
First-level cache always Associates with the Session object. Hibernate uses this cache by default. Here, it processes one transaction after another one, means wont process one transaction many times. Mainly it reduces the number of SQL queries it needs to generate within a given transaction. That is instead of updating after every modification done in the transaction, it updates the transaction only at the end of the transaction.
Second level cache
Second-level cache always associates with the Session Factory object. While running the transactions, in between it loads the objects at the Session Factory level, so that those objects will be available to the entire application, not bound to single user. Since the objects are already loaded in the cache, whenever an object is returned by the query, at that time no need to go for a database transaction. In this way the second level cache works. Here we can use query level cache also. Later we will discuss about it.
LinkedList over ArrayList
LinkedList is also the implementation of Queue inteface. It works on FIFO(First In First Out mode).
LinkedList is better to insert or delete the elements of the list than the ArrayList.
HashMap vs HashTable
Both the collections implements Map:
1. HashMap is not synchronized but HashTable is synchronized.
2. HashMap accepts null values and one null key whereas HashTable does not allow null key and value.
Difference between Iterator and ListIterator
1. Iterator can iterate a collection only in forward direction whereas through ListIterator we can iterate the collection in both forward and backword direction.
2. Iterator can be used for all the collection like List, Set , Map whereas ListIterator can only be used for List collection.
Difference between ArrayList and Vector
There are main two difference between ArrayList and Vector
1. Synchronization: ArrayList is not synchronized , but Vector is synchronized.
Because ArraList is not synchronized so it is not thread safe. Vector is thread safe.
Because Vector is thread safe, in terms of performance Vector is slower than ArrayList.
2. Data size Increament: ArrayList increase its size 50% whereas Vector increase its size as double.
What is legacy class in java?
In earlier versions of Java, there were some classes which was used in place of Collections framework, those classes were known as Legacy classes.
Legacy classes were used earlier to save the object state.
Example: Vector is a Legacy class.