aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Transient, Persistance? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Transient, Persistance?" Watch "Transient, Persistance?" New topic
Author

Transient, Persistance?

Ajay Singhal
Ranch Hand

Joined: Jan 10, 2001
Posts: 37
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

Joined: Jan 02, 2001
Posts: 35
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

Joined: Jan 10, 2001
Posts: 37
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

Joined: Jan 02, 2001
Posts: 35
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Transient, Persistance?
 
Similar Threads
Serialization concept
Which of the Following is True?
how to exclude a class member from hibernate mapping?
Cattle Drive Hall of Fame
making a mostly anonymous Comparator be Serializable