answersLogoWhite

0

What is serializable?

Updated: 12/8/2022
User Avatar

Venu3055

Lvl 1
15y ago

Best Answer

Ideally, transactions should be serializable. Transactions are said to be serializable if the results of running transactions simultaneously are the same as the results of running them serially-that is, one after the other. It is not important which transaction executes first, only that the result does not reflect any mixing of the transactions.

For example, suppose transaction A multiplies data values by 2 and transaction B adds 1 to data values. Now suppose that there are two data values: 0 and 10. If these transactions are run one after the other, the new values will be 1 and 21 if transaction A is run first, or 2 and 22 if transaction B is run first. But what if the order in which the two transactions are run is different for each value? If transaction A is run first on the first value and transaction B is run first on the second value, the new values are 1 and 22. If this order is reversed, the new values are 2 and 21. The transactions are serializable if 1, 21 and 2, 22 are the only possible results. The transactions are not serializable if 1, 22 or 2, 21 is a possible result.

So why is serializability desirable? In other words, why is it important that it appears that one transaction finishes before the next transaction starts? Consider the following problem. A salesman is entering orders at the same time a clerk is sending out bills. Suppose the salesman enters an order from Company X but does not commit it; the salesman is still talking to the representative from Company X. The clerk requests a list of all open orders and discovers the order for Company X and sends them a bill. Now the representative from Company X decides they want to change their order, so the salesman changes it before committing the transaction. Company X gets an incorrect bill.

If the salesman's and clerk's transactions were serializable, this problem would never have occurred. Either the salesman's transaction would have finished before the clerk's transaction started, in which case the clerk would have sent out the correct bill, or the clerk's transaction would have finished before the salesman's transaction started, in which case the clerk would not have sent a bill to Company X at all.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

15y ago

Serialization means saving the state of an object by converting it into byte stream.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is serializable?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What in java is not serializable?

Objects that do not implement Serializable.


What is serializable class in JAVA?

The serializable interface is used to perform the serialization action. Serialization is the process by which the contents of an object are written to any form of storage - say a flat file. This data stored in the flat file can be de-serialized at any time to create the object. Ex: public class Test implements Serializable { … //lots of code }


Can a nested object be used in Serialization?

Yes, provide that object and its object references (the instance variables of that object that are of other object types) is also Serializable, or marked as [NonSerialized]


What is a transient variable?

Transient variable can't be serialize. For example if a variable is declared as transient in a Serializable class and the class is written to an ObjectStream, the val ue of the variable can't be written to the stream instead when the class is retrieved from the ObjectStream the value of the variable becomes null


What is serialization in Java?

Serialization is the ability to easily store the state of an Object in memory onto some long-term medium (on a hard drive, for example). Basically, the Serializable interface allows us to tell Java to turn our Object into a byte-stream. The Object could be a document that the user is working on, or a more complex data class which needs the ability to be saved to the hard drive. Using the Serializable interface (and related I/O methods), Java will do most of the work for us.

Related questions

What in java is not serializable?

Objects that do not implement Serializable.


Can you serialize the ArrayList class in Java?

The ArrayList class itself is serializable and will serialize if it contains only serializable objects.If, however, you add non-serializable objects into the list then it will not serialize, but will throw a NotSerializableException.


What is serializable class in JAVA?

The serializable interface is used to perform the serialization action. Serialization is the process by which the contents of an object are written to any form of storage - say a flat file. This data stored in the flat file can be de-serialized at any time to create the object. Ex: public class Test implements Serializable { … //lots of code }


Serial schedule differs serializable schedule in dbms?

Serial schedules are the schedules during which all statements in a transaction are executed consecutively. Serializable schedule is a schedule that is equivalent to a serial schedule


What is the difference between Serializable and Parcelable Which is the best approach in Android?

"Typically, data must be transferred from one activity to another while designing apps. A related intent object has to include this data. To get the data ready for transfer, certain further steps are needed. The object needs to be parcelable or serializable to accomplish that. Serializable: Serializable is a Java interface that is widely used. With this method, you merely implement the interface to designate a class as serializable, and Java will do the rest. The technique makes use of reflection, and numerous new things are produced. The result is the heavy rubbish collection and subpar performance. Parcelable: An Android-specific interface is called Parcelable. You carry out the serialization by yourself in this method. Because reflection is not employed in this operation, no garbage is produced. Since Parcelable circumvents various issues with the built-in Java serialization mechanism, it is significantly more efficient than Serializable. It is also quicker and produces better - results because it has been tailored for use in the development of Android."


What is the difference between serial and serializable schedule?

A serial schedule is when all the operations of one transactions appear together (not mixed with the operations of any other transactions on the schedule). A serializable schedule is a weaker term -- it is a schedule where the operations of different transactions may be mixed together on the schedule, so long as they are conflict-equivalent to some serial schedule.


What is the difference between conflict equivalence and view equivalence of dbms?

Conflict equivalence- Two schedules are conflict equivalent if the order of any two conflicting operations is same in both the two schedules. View equivalence- Two schedules are view equivalent if - 1) Both the schedules have same set of transactions. 2) If in a schedule a read operation r1[X] of transaction T1 reads the value of X written by a write operation w2[x] of transaction T2 or reads the original value of x,then this must also be the case in the other schedule. 3)If operation w3[Y] of a transaction is the last operation to write the value of Y in schedule S then it must also be the last transaction in the other schedule to do so. All conflict serializable schedules are view serializable. But all view serializable schedules are not conflict serializable.


What is Externalizable interface?

The Externizable interface extends the serializable interface.When you use Serializable interface, your class is serialized automatically by default. But you can override writeObject() and readObject()two methods to control more complex object serailization process. When you use Externalizable interface, you have a complete control over your class's serialization process. The two methods to be implemented are :void readExternal(ObjectInput)void writeExternal(ObjectOutput)


Can a nested object be used in Serialization?

Yes, provide that object and its object references (the instance variables of that object that are of other object types) is also Serializable, or marked as [NonSerialized]


How is Java persistence done?

Java persistence is implemented using serialization. Serialization is a technique in java using which the contents of a java object (A class instance) can be written into a flat file. This value can be unserialized or deserialized at a later point of time to create the object. Any class that implements the Serializable interface can be serialized.


What is a transient variable?

Transient variable can't be serialize. For example if a variable is declared as transient in a Serializable class and the class is written to an ObjectStream, the val ue of the variable can't be written to the stream instead when the class is retrieved from the ObjectStream the value of the variable becomes null


What is serialization in Java?

Serialization is the ability to easily store the state of an Object in memory onto some long-term medium (on a hard drive, for example). Basically, the Serializable interface allows us to tell Java to turn our Object into a byte-stream. The Object could be a document that the user is working on, or a more complex data class which needs the ability to be saved to the hard drive. Using the Serializable interface (and related I/O methods), Java will do most of the work for us.