Why Hibernate entities needs to implement serializable interface do we really need it always or for some scenarios.???
As per oracle docs
"If an entity instance be passed by value as a detached object, such as through a session bean’s remote business interface, the class must implement the Serializable interface."
So its look like it is required in some scenarios but its not mandatory.So may be we take it as a best practice so it would be compatible to use all scenarios. There could be scenarios where we may have to pass JPA pojo or Entity as a value holder object from one layer to another to avoid use of DTO's (Data Transfer object). Which we use by copy & pass the data to next layers. Some time we may need to pass them over Http layers as a session object may be from presentation layer to business layer. So its content need to be serializable. So we reached on conclusion that its better is most of cases to implement serializable marker interface.
why we have 2 types of annotations in hibernate.First which starts from javax.persistence.* & another one which are like org.hibernate.annotations.* ??????
So one type is JPA based which are javax.persistence & another one is Hibernate based which are org.hibernate.annotations. Hibernate take advantage from JPA annotations as they are applicable in all JPA compliant ORM tools.One more point is JPA annotations are basic one & hibernation annotations are providing extra feature.So one should first with JPA & if required should move towards Hibernate annotations.
JPA Basic annotations:
JPA Mapping annotations
JAP inheritance annotations
While above JPA basic annotations is good to be used in simple application Hibernate annotations are present for some advanced user or applications.
Hibernate annotations for Queries
As a Query Hints
Whether the query should interact with the second level cache (defualt to false);
Cache region name (default used otherwise)
resultset fetch size
Flush mode used for this query
Cache mode used for this query
Entities loaded by this query should be in read only mode or not (default to false)
Query comment added to the generated SQL
Hibernate annotations for Runtime filters
@org.hibernate.annotations.FilterDef or @FilterDefs define filter definition(s) used by filter(s) using the same name. A filter definition has a name() and an array of parameters(). A parameter will allow you to adjust the behavior of the filter at runtime
Some time we got machine to work where we don't have access rights to install anything or if you do not want to install. You can get latest jdk running by this trick. Just follow step step & do comment if you like it.
5.Go inside E:\jdk-8u102-windows-x64\.rsrc\1033\JAVA_CAB10you will find 111 file.
6.extract it it some folder where you can find tools.zip again extract that to some folder say Java & copy it to very first folder of setup along with .data,.rsrc etc.
7.Go to folder where you have co…
Multi threading is topic which is always fascinating for java developer. I feel its more about practical the theory. So here i wanted to present sample examples which clear understanding for several multi threading concept.
In Theory basically thread which is light weight process.Thread shares mostly same memory space.
I said mostly because there is some space called thread local which is not common to threads & separate for each thread. We create thread whenever we wanted to use multicore of processor although that doesn't mean single core cant use it. In single core context switching works among different running thread.
for example suppose there is website which is showing latest price as well as offer as well as doing order booking all these things can be assigned to different thread to provide parallel processing.
There are 2 ways for creating a thread.
Extend a thread & Implement a Runnable class. Extending a class is little avoided since it closed possibility for e…