Showing posts with label Transient. Show all posts
Showing posts with label Transient. Show all posts

Wednesday, February 24, 2016

What is transient in Java ?

About transient 
transient is a keyword which is used with the member variable of a class to exclude a particular variable from the serialization process (In serialization an object state is saved in bytestream by JVM).

One cannot use the transient keyword with the static variable.

transient variable initialized with the default value during de-serialization
(In Deserialization process object state is recovered by JVM except the static and transient variablers)

also take a look at the what is volatile keyword in java

Advantage
many times as a developer we do not want to serialize some members of object at that one can use the transient keyword and it gives us flexibility in this case as per our requirement.

UseCase
may times some variables value is dependent on other variable, means we can gain value of particular variable from other variables value at that time we can exclude particular variable from being serialization process.
sometimes we use some members of class just for logs purpose those variables also no need to be serialize.

Wednesday, October 21, 2015

Hibernate Transient + Persistent + Detached Objects

Transient Object :
One newly created object of POJO class without having any relation with the database, means
never persistent, not associated with any Session object.

Persistent Object:
An object of a POJO class having relation with the database, associated with a unique Session
object

Detached Object:
An object of a POJO class Previously having relation with the database [persistent ], now not
associated with any Session object

Hibernate Object's Transient & Persistent states


Whenever an object of a POJO class is created then it will be in the Transient state
An object in a Transient state doesn’t represent any row of the database,

Means it is not associated with any Session object, No relation with the database, it is just a
normal object

 If we modify the data of a POJO class object, when it is in transient state then it doesn’t effect
on the database table

When the object is in persistent state, then it represent one row of the database,

In persistent state object is having associated with the unique Session

If we want to move an object from persistent to detached state, then we need to do either
close that session or need to clear the cache of the session

If we want to move an object from persistent state into transient state then we need to delete
that object permanently from the database

Scrum and Scrum master

Scrum  Scrum is a framework which helps a team to work together.  It is like a rugby team (the scrum name comes from rugby game). Scrum enco...