serializable

Why does HttpServlet implement Serializable?

In my understanding of Servlet, the Servlet will be instantiated by the Container, his init() method will be called once, and the servlet will live like a singleton until the jvm is shut down. i do not expect my servlet to be serialized, since it will be constructed new when the app server recovers or is starting up normally. the servle...

Calling Dibs on a table row

The problem I have is this: I have a table (just an example) with the following fields: ID int Value int I have a method called IncreaseByFive() which does the following: method IncreaseByFive(int ID) { int value = GetValueFromDB(ID); value = value + 5; SaveValueToDB(value, ID); } What I want to avoid is the fo...

When using ISerializable with DataContractSerializer, how do I stop the serializer from outputting type information?

To get more control over serialization, I have converted a class from [DataContract] to [Serializable], implementing both GetObjectData and the special deserializing constructor. When I do this, the XML emitted now has type information applied to all elements. I don't want this superfluous information, and I'm wondering how to inform t...

Exception, Return, Serializable,

How does (throw Exception) and (return value) is implemented in a Language such as Java or C#? I want to know the mechanism how its support is included in a Language and not just the usage of try { .... } catch (Exception) {} ? We know when we call a function i.e. public void doSomething() { .... .... return; } Then on the call ...

Serializing private member data

I'm trying to serialize an object to XML that has a number of properties, some of which are readonly. public Guid Id { get; private set; } I have marked the class [Serializable] and I have implemented the ISerializable interface. Below is the code I'm using to serialize my object. public void SaveMyObject(MyObject obj) { XmlSeri...

What is the point of the ISerializable interface?

It seems like I can serialize classes that don't have that interface, so I am unclear on its purpose. ...

How can I add a type constraint to include anything serializable in a generic method?

My generic method needs to serialize the object passed to it, however just insisting that it implements ISerializable doesn't seem to work. For example, I have a struct returned from a web service (marked with SerializableAttribute) that serializes to xml just fine, but, as expected, the C# compiler complains. Is there a way I can check...

Who actually implements serializable methods?

I've been learning how to use Serializable. I know if I create a class 'A' with different variables who implements Serializable and I add Serializable to my class, it's also Serializable. But, who is actually implementing those two methods to serialize? Does Object take care of everything or different classes overloads them when necess...

Will adding a method change the java-calculated serialVersionUid on my class?

Hi All, If I have a class like this: public class Name implements Serializable { private final String firstName; private final String lastName; public Name(String firstName, String lastName) { this.firstName = firstName; this.lastName = lastName; } public String getFirstName() { return first...

Why should I always make my Exceptions [serializable]? (.NET)

Referring to What is the correct way to make a custom .NET Exception serializable? and Are all .NET Exceptions serializable? ... Why should my exceptions be serializable? Someone said "it can be considered a bug" if a custom exception defined by a third party library, is not serializable. Why? Why are exceptions different than oth...

re: design of custom exceptions: must I implement the default constructor? the "inner exception" constructor?

The answer to What is the correct way to make exceptions serializable? says that the "correct" base implementation for a custom exception includes 4 ctors: [Serializable] public class SerializableExceptionWithoutCustomProperties : Exception { public SerializableExceptionWithoutCustomProperties() { } public Serializabl...

What is a serializable object ?

What is a serializable object in C#? I guess the word serializable is throwing me off more than "serializable object". ...

Does adding [Serializable] to the class have any performance implications?

I need to add the [Serializable] attribute to a class that is extremely performance sensitive. Will this attribute have any performance implications on the operation of the class? ...

Python serializable objects json

class gpagelet: """ Holds 1) the pagelet xpath, which is a string 2) the list of pagelet shingles, list """ def __init__(self, parent): if not isinstance( parent, gwebpage): raise Exception("Parent must be an instance of gwebpage") self.parent = parent # This must be a gwebpage...

android: problem with Serializable object put into intent

Hi i have problem with a class i want to pass in an intent by putting it into the putExtras() Its serializable and the code looks like this: public abstract class ObjectA extends ArrayList<ObjectA> implements java.io.Serializable{...} public class ObjectB extends ObjectA {...} ... Bundle extras = new Bundle(); extras.putSerializable(...

How to generate web service proxy code with wsdl.exe that is serializable

I am using wsdl.exe to auto generate the web service proxy code from a huge wsdl file. I then take the .cs file it generates compile it to a dll and use it in my program to make web service calls. The problem is that when using sql session state in my program I can not save the proxxy object to session state. I marked the main class in ...

Serializable exception and WCF

if i made my exception Serializable like this article from msdn , so can my exception serialized over WCF ? ...

Does Java Serialization work for cyclic references?

For example: Object A contains Object B that contains Object C that contains Object A. Will Object A serialize properly? Comment #9 here indicates that it does not work . In contrast, XStream indicates that it does handle cyclic references. ...

Serializable and transient

To make class serializable we do the following: class A implements Serializable { transient Object a; } And why not: serializable class A { transient Object a; } Why if we want to make class serializable we implement special interface. And if we want to exclude some fields we use keyword "transient"? Why special keywords are...

Is there an XML specific object (like XElement) that is binary serializable?

I have a use case where I am serializing objects over the wire via MSMQ (mostly strings). When I read the object off the queue I want to be able to tell if the user meant for the object to be a XML or a string. I was thinking a good way to do this would just be to check the type. If it's XmlElement than it becomes XML data otherwise it...