• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Transient, Persistance?

 
Ajay Singhal
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! everyone
I am confused with the term transient and Persistance.
can anyone help me on these topics.
i'll be pleased if u'll give an example.
------------------
 
Konda Balabbigari
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ajay
In Java when the class is implementing java.io.Serializable interface then the instance of that class can be written out to a disk or to a database. When the object is written out all the data belong to that object also written out.
If any variable is marked as "transient" that variable will not be written out to disk or to a database.
Example:
import java.io.*;
public class MyTransient implements Serializable {
// String s will be written out
public String s = "Test";
// String s1 will not be written out
public transient String s1 = "Test Transient" ;

public static void main ( String args[]) {
// here use the io methods to write out the object
}
}
Thanks
Konda Balabbigari
Web: http://www.javacaps.com
 
Ajay Singhal
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! Konda Balabbigari
thanX for ur information really transient is now clear to me.
will u please tell me something about persistance?


------------------
 
Konda Balabbigari
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ajay
Persistence is process ( mechanism ) of storing/retrieving the object's state from the relational database. This process is well defined in Enterprise JavaBeans becasue Entity Benas are persistable objects.
For example if any class implementing the java.io.Serializable interface ( it just a marker interface ) then that object's state can be stored in a database. The Serializable interface makes it posible.
I think Ajay you may not worry much about this for SCJP certification.
Thanks
Konda Balabbigari
Web: http://www.javacaps.com
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic